@@ -36,6 +36,7 @@ discard block |
||
| 36 | 36 | * @param string $password |
| 37 | 37 | * @param array $options |
| 38 | 38 | * @param boolean|string $cache |
| 39 | + * @param string $dbType |
|
| 39 | 40 | */ |
| 40 | 41 | public function __construct($dbType, $dbName, $serverName = "localhost", $port = "3306", $user = "root", $password = "", $options = [], $cache = false) { |
| 41 | 42 | $this->dbType = $dbType; |
@@ -122,6 +123,9 @@ discard block |
||
| 122 | 123 | return $result; |
| 123 | 124 | } |
| 124 | 125 | |
| 126 | + /** |
|
| 127 | + * @param string $sql |
|
| 128 | + */ |
|
| 125 | 129 | public function prepareAndFetchAll($sql,$parameters=null){ |
| 126 | 130 | $result=false; |
| 127 | 131 | $statement=$this->getStatement($sql); |
@@ -144,6 +148,9 @@ discard block |
||
| 144 | 148 | return $result; |
| 145 | 149 | } |
| 146 | 150 | |
| 151 | + /** |
|
| 152 | + * @param string $sql |
|
| 153 | + */ |
|
| 147 | 154 | public function prepareAndFetchColumn($sql,$parameters=null,$column=null){ |
| 148 | 155 | $statement=$this->getStatement($sql); |
| 149 | 156 | if($statement->execute ($parameters)){ |
@@ -209,7 +216,7 @@ discard block |
||
| 209 | 216 | /** |
| 210 | 217 | * Returns the last insert id |
| 211 | 218 | * |
| 212 | - * @return integer |
|
| 219 | + * @return string |
|
| 213 | 220 | */ |
| 214 | 221 | public function lastInserId() { |
| 215 | 222 | return $this->pdoObject->lastInsertId (); |
@@ -234,6 +241,9 @@ discard block |
||
| 234 | 241 | return $this->query ( "SELECT COUNT(*) FROM " . $tableName . $condition )->fetchColumn (); |
| 235 | 242 | } |
| 236 | 243 | |
| 244 | + /** |
|
| 245 | + * @param string $query |
|
| 246 | + */ |
|
| 237 | 247 | public function queryColumn($query){ |
| 238 | 248 | return $this->query ( $query )->fetchColumn (); |
| 239 | 249 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * Loads member associated with $instance by a ManyToOne relationship |
| 32 | 32 | * @param object $instance |
| 33 | 33 | * @param string $member |
| 34 | - * @param boolean|array $included if true, loads associate members with associations, if array, example : ["client.*","commands"] |
|
| 34 | + * @param boolean $included if true, loads associate members with associations, if array, example : ["client.*","commands"] |
|
| 35 | 35 | * @param boolean $useCache |
| 36 | 36 | */ |
| 37 | 37 | public static function getManyToOne($instance, $member, $included=false,$useCache=NULL) { |
@@ -115,6 +115,11 @@ discard block |
||
| 115 | 115 | return $ret; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | + /** |
|
| 119 | + * @param string $member |
|
| 120 | + * @param string $class |
|
| 121 | + * @param string $part |
|
| 122 | + */ |
|
| 118 | 123 | private static function setToMember($member, $instance, $value, $class, $part) { |
| 119 | 124 | $accessor="set" . ucfirst($member); |
| 120 | 125 | if (method_exists($instance, $accessor)) { |
@@ -167,6 +172,10 @@ discard block |
||
| 167 | 172 | } |
| 168 | 173 | } |
| 169 | 174 | |
| 175 | + /** |
|
| 176 | + * @param string $class |
|
| 177 | + * @param ManyToManyParser $parser |
|
| 178 | + */ |
|
| 170 | 179 | private static function getManyToManyFromArray($instance, $array, $class, $parser) { |
| 171 | 180 | $ret=[]; |
| 172 | 181 | $continue=true; |
@@ -200,7 +209,7 @@ discard block |
||
| 200 | 209 | * @param string $className class name of the model to load |
| 201 | 210 | * @param string $condition Part following the WHERE of an SQL statement |
| 202 | 211 | * @param boolean|array $included if true, loads associate members with associations, if array, example : ["client.*","commands"] |
| 203 | - * @param array|null $parameters |
|
| 212 | + * @param boolean $parameters |
|
| 204 | 213 | * @param boolean $useCache use the active cache if true |
| 205 | 214 | * @return array |
| 206 | 215 | */ |
@@ -208,6 +217,10 @@ discard block |
||
| 208 | 217 | return self::_getAll($className, new ConditionParser($condition,null,$parameters),$included,$useCache); |
| 209 | 218 | } |
| 210 | 219 | |
| 220 | + /** |
|
| 221 | + * @param string $className |
|
| 222 | + * @param boolean|null $useCache |
|
| 223 | + */ |
|
| 211 | 224 | protected static function _getOne($className,ConditionParser $conditionParser,$included,$useCache){ |
| 212 | 225 | $conditionParser->limitOne(); |
| 213 | 226 | $retour=self::_getAll($className, $conditionParser, $included,$useCache); |
@@ -257,6 +270,9 @@ discard block |
||
| 257 | 270 | return $objects; |
| 258 | 271 | } |
| 259 | 272 | |
| 273 | + /** |
|
| 274 | + * @param string $condition |
|
| 275 | + */ |
|
| 260 | 276 | public static function paginate($className,$page=1,$rowsPerPage=20,$condition=null,$included=true){ |
| 261 | 277 | if(!isset($condition)){ |
| 262 | 278 | $condition="1=1"; |
@@ -319,7 +335,7 @@ discard block |
||
| 319 | 335 | * @param string $className complete classname of the model to load |
| 320 | 336 | * @param string $condition Part following the WHERE of an SQL statement |
| 321 | 337 | * @param array|null $parameters The query parameters |
| 322 | - * @return int count of objects |
|
| 338 | + * @return string|false count of objects |
|
| 323 | 339 | */ |
| 324 | 340 | public static function count($className, $condition='',$parameters=null) { |
| 325 | 341 | $tableName=OrmUtils::getTableName($className); |
@@ -333,7 +349,7 @@ discard block |
||
| 333 | 349 | * @param String $className complete classname of the model to load |
| 334 | 350 | * @param Array|string $keyValues primary key values or condition |
| 335 | 351 | * @param boolean|array $included if true, charges associate members with association |
| 336 | - * @param array|null $parameters the request parameters |
|
| 352 | + * @param boolean|null $parameters the request parameters |
|
| 337 | 353 | * @param boolean $useCache use cache if true |
| 338 | 354 | * @return object the instance loaded or null if not found |
| 339 | 355 | */ |
@@ -13,9 +13,21 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | protected static $annotFieldsInRelations=[]; |
| 15 | 15 | |
| 16 | + /** |
|
| 17 | + * @param string $className |
|
| 18 | + * @param boolean $useCache |
|
| 19 | + */ |
|
| 16 | 20 | abstract protected static function _getAll($className, ConditionParser $conditionParser, $included=true,$useCache=NULL); |
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @param string $className |
|
| 24 | + * @param boolean|null $useCache |
|
| 25 | + */ |
|
| 17 | 26 | abstract protected static function _getOne($className,ConditionParser $conditionParser,$included,$useCache); |
| 18 | 27 | |
| 28 | + /** |
|
| 29 | + * @param string $className |
|
| 30 | + */ |
|
| 19 | 31 | protected static function uParse($className,&$ucondition){ |
| 20 | 32 | $expressions=self::uGetExpressions($ucondition); |
| 21 | 33 | $condition=""; |
@@ -62,7 +74,7 @@ discard block |
||
| 62 | 74 | /** |
| 63 | 75 | * Returns an array of $className objects from the database |
| 64 | 76 | * @param string $className class name of the model to load |
| 65 | - * @param string $condition UQL condition |
|
| 77 | + * @param string $ucondition UQL condition |
|
| 66 | 78 | * @param boolean|array $included if true, loads associate members with associations, if array, example : ["client.*","commands"] |
| 67 | 79 | * @param array|null $parameters the request parameters |
| 68 | 80 | * @param boolean $useCache use the active cache if true |