1 2/* 3 +------------------------------------------------------------------------+ 4 | Phalcon Framework | 5 +------------------------------------------------------------------------+ 6 | Copyright (c) 2011-2017 Phalcon Team (https://phalconphp.com) | 7 +------------------------------------------------------------------------+ 8 | This source file is subject to the New BSD License that is bundled | 9 | with this package in the file LICENSE.txt. | 10 | | 11 | If you did not receive a copy of the license and are unable to | 12 | obtain it through the world-wide-web, please send an email | 13 | to license@phalconphp.com so we can send you a copy immediately. | 14 +------------------------------------------------------------------------+ 15 | Authors: Andres Gutierrez <andres@phalconphp.com> | 16 | Eduar Carvajal <eduar@phalconphp.com> | 17 +------------------------------------------------------------------------+ 18 */ 19 20namespace Phalcon\Mvc\Model; 21 22use Phalcon\DiInterface; 23 24/** 25 * Phalcon\Mvc\Model\CriteriaInterface 26 * 27 * Interface for Phalcon\Mvc\Model\Criteria 28 */ 29interface CriteriaInterface 30{ 31 32 /** 33 * Set a model on which the query will be executed 34 */ 35 public function setModelName(string! modelName) -> <CriteriaInterface>; 36 37 /** 38 * Returns an internal model name on which the criteria will be applied 39 */ 40 public function getModelName() -> string; 41 42 /** 43 * Sets the bound parameters in the criteria 44 * This method replaces all previously set bound parameters 45 */ 46 public function bind(array! bindParams, boolean merge = false) -> <CriteriaInterface>; 47 48 /** 49 * Sets the bind types in the criteria 50 * This method replaces all previously set bound parameters 51 */ 52 public function bindTypes(array! bindTypes) -> <CriteriaInterface>; 53 54 /** 55 * Sets the conditions parameter in the criteria 56 */ 57 public function where(string! conditions, var bindParams = null, var bindTypes = null) -> <CriteriaInterface>; 58 59 /** 60 * Adds the conditions parameter to the criteria 61 */ 62 public function conditions(string! conditions) -> <CriteriaInterface>; 63 64 /** 65 * Adds the order-by parameter to the criteria 66 */ 67 public function orderBy(string! orderColumns) -> <CriteriaInterface>; 68 69 /** 70 * Sets the limit parameter to the criteria 71 * 72 * @param int limit 73 * @param int offset 74 * @return \Phalcon\Mvc\Model\CriteriaInterface 75 */ 76 public function limit(int limit, var offset = null) -> <CriteriaInterface>; 77 78 /** 79 * Sets the "for_update" parameter to the criteria 80 */ 81 public function forUpdate(boolean forUpdate = true) -> <CriteriaInterface>; 82 83 /** 84 * Sets the "shared_lock" parameter to the criteria 85 */ 86 public function sharedLock(boolean sharedLock = true) -> <CriteriaInterface>; 87 88 /** 89 * Appends a condition to the current conditions using an AND operator 90 * 91 * @param string conditions 92 * @param array bindParams 93 * @param array bindTypes 94 * @return \Phalcon\Mvc\Model\CriteriaInterface 95 */ 96 public function andWhere(string! conditions, var bindParams = null, var bindTypes = null) -> <CriteriaInterface>; 97 98 /** 99 * Appends a condition to the current conditions using an OR operator 100 * 101 * @param string conditions 102 * @param array bindParams 103 * @param array bindTypes 104 * @return \Phalcon\Mvc\Model\CriteriaInterface 105 */ 106 public function orWhere(string! conditions, var bindParams = null, var bindTypes = null) -> <CriteriaInterface>; 107 108 /** 109 * Appends a BETWEEN condition to the current conditions 110 * 111 *<code> 112 * $criteria->betweenWhere("price", 100.25, 200.50); 113 *</code> 114 * 115 * @param string expr 116 * @param mixed minimum 117 * @param mixed maximum 118 * @return \Phalcon\Mvc\Model\CriteriaInterface 119 */ 120 public function betweenWhere(string! expr, var minimum, var maximum) -> <CriteriaInterface>; 121 122 /** 123 * Appends a NOT BETWEEN condition to the current conditions 124 * 125 *<code> 126 * $criteria->notBetweenWhere("price", 100.25, 200.50); 127 *</code> 128 * 129 * @param string expr 130 * @param mixed minimum 131 * @param mixed maximum 132 * @return \Phalcon\Mvc\Model\CriteriaInterface 133 */ 134 public function notBetweenWhere(string! expr, var minimum, var maximum) -> <CriteriaInterface>; 135 136 /** 137 * Appends an IN condition to the current conditions 138 * 139 *<code> 140 * $criteria->inWhere("id", [1, 2, 3]); 141 *</code> 142 */ 143 public function inWhere(string! expr, array! values) -> <CriteriaInterface>; 144 145 /** 146 * Appends a NOT IN condition to the current conditions 147 * 148 *<code> 149 * $criteria->notInWhere("id", [1, 2, 3]); 150 *</code> 151 */ 152 public function notInWhere(string! expr, array! values) -> <CriteriaInterface>; 153 154 /** 155 * Returns the conditions parameter in the criteria 156 * 157 * @return string|null 158 */ 159 public function getWhere(); 160 161 /** 162 * Returns the conditions parameter in the criteria 163 * 164 * @return string|null 165 */ 166 public function getConditions(); 167 168 /** 169 * Returns the limit parameter in the criteria, which will be 170 * an integer if limit was set without an offset, 171 * an array with 'number' and 'offset' keys if an offset was set with the limit, 172 * or null if limit has not been set. 173 * 174 * @return int|array|null 175 */ 176 public function getLimit(); 177 178 /** 179 * Returns the order parameter in the criteria 180 * 181 * @return string|null 182 */ 183 public function getOrderBy(); 184 185 /** 186 * Returns all the parameters defined in the criteria 187 * 188 * @return array 189 */ 190 public function getParams(); 191 192 /** 193 * Executes a find using the parameters built with the criteria 194 */ 195 public function execute() -> <ResultsetInterface>; 196 197} 198