Complex classes like FluentPdoModel often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use FluentPdoModel, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 37 | class FluentPdoModel |
||
| 38 | { |
||
| 39 | const OPERATOR_AND = ' AND '; |
||
| 40 | const OPERATOR_OR = ' OR '; |
||
| 41 | const ORDERBY_ASC = 'ASC'; |
||
| 42 | const ORDERBY_DESC = 'DESC'; |
||
| 43 | const SAVE_INSERT = 'INSERT'; |
||
| 44 | const SAVE_UPDATE = 'UPDATE'; |
||
| 45 | const LEFT_JOIN = 'LEFT'; |
||
| 46 | const INNER_JOIN = 'INNER'; |
||
| 47 | const ONE_DAY = 86400; |
||
| 48 | const ONE_WEEK = 60480060; |
||
| 49 | const ONE_HOUR = 3600; |
||
| 50 | const TEN_MINS = 600; |
||
| 51 | const CACHE_NO = -1; |
||
| 52 | const CACHE_DEFAULT = 0; |
||
| 53 | |||
| 54 | /** @var AbstractPdo $_connection */ |
||
| 55 | protected $_connection = null; |
||
| 56 | |||
| 57 | /** @var string */ |
||
| 58 | protected $_primary_key = 'id'; |
||
| 59 | |||
| 60 | /** @var array */ |
||
| 61 | protected $_where_parameters = []; |
||
| 62 | |||
| 63 | /** @var array */ |
||
| 64 | protected $_select_fields = []; |
||
| 65 | |||
| 66 | /** @var array */ |
||
| 67 | protected $_join_sources = []; |
||
| 68 | |||
| 69 | /** @var array */ |
||
| 70 | protected $_join_aliases = []; |
||
| 71 | |||
| 72 | /** @var array $_associations */ |
||
| 73 | protected $_associations = [ |
||
| 74 | 'belongsTo' => [], |
||
| 75 | ]; |
||
| 76 | |||
| 77 | /** @var array */ |
||
| 78 | protected $_where_conditions = []; |
||
| 79 | |||
| 80 | protected $_raw_sql = null; |
||
| 81 | |||
| 82 | /** @var int */ |
||
| 83 | protected $_limit = null; |
||
| 84 | |||
| 85 | /** @var int */ |
||
| 86 | protected $_offset = null; |
||
| 87 | |||
| 88 | /** @var array */ |
||
| 89 | protected $_order_by = []; |
||
| 90 | |||
| 91 | /** @var array */ |
||
| 92 | protected $_group_by = []; |
||
| 93 | |||
| 94 | /** @var string */ |
||
| 95 | protected $_and_or_operator = self::OPERATOR_AND; |
||
| 96 | |||
| 97 | /** @var array */ |
||
| 98 | protected $_having = []; |
||
| 99 | |||
| 100 | /** @var bool */ |
||
| 101 | protected $_wrap_open = false; |
||
| 102 | |||
| 103 | /** @var int */ |
||
| 104 | protected $_last_wrap_position = 0; |
||
| 105 | |||
| 106 | /** @var PDOStatement $_pdo_stmt */ |
||
| 107 | protected $_pdo_stmt = null; |
||
| 108 | |||
| 109 | /** @var bool */ |
||
| 110 | protected $_distinct = false; |
||
| 111 | |||
| 112 | /** @var null */ |
||
| 113 | protected $_requested_fields = []; |
||
| 114 | |||
| 115 | /** @var null */ |
||
| 116 | protected $_filter_meta = []; |
||
| 117 | |||
| 118 | /** @var bool */ |
||
| 119 | protected $_log_queries = false; |
||
| 120 | |||
| 121 | /** @var array */ |
||
| 122 | protected $_timer = []; |
||
| 123 | |||
| 124 | /** @var int */ |
||
| 125 | protected $_slow_query_secs = 5; |
||
| 126 | |||
| 127 | /** @var array */ |
||
| 128 | protected $_pagination_attribs = [ |
||
| 129 | '_limit', |
||
| 130 | '_offset', |
||
| 131 | '_order', |
||
| 132 | '_fields', |
||
| 133 | '_search' |
||
| 134 | ]; |
||
| 135 | |||
| 136 | /** @var string $_table_name */ |
||
| 137 | protected $_table_name = null; |
||
| 138 | |||
| 139 | /** @var string $_table_alias */ |
||
| 140 | protected $_table_alias = null; |
||
| 141 | |||
| 142 | /** @var string $_display_column */ |
||
| 143 | protected $_display_column = null; |
||
| 144 | |||
| 145 | /** @var string $_connection_name */ |
||
| 146 | protected $_connection_name = null; |
||
| 147 | |||
| 148 | /** @var array $_schema */ |
||
| 149 | protected $_schema = []; |
||
| 150 | |||
| 151 | /** @var array $_virtual_fields */ |
||
| 152 | protected $_virtual_fields = []; |
||
| 153 | |||
| 154 | /** @var array $_errors */ |
||
| 155 | protected $_errors = []; |
||
| 156 | |||
| 157 | /** |
||
| 158 | * @var int - true = connection default x days |
||
| 159 | * - false = no cache |
||
| 160 | * - int = a specific amount |
||
| 161 | */ |
||
| 162 | protected $_cache_ttl = self::CACHE_NO; |
||
| 163 | |||
| 164 | /** @var string */ |
||
| 165 | protected $_tmp_table_prefix = 'tmp_'; |
||
| 166 | |||
| 167 | /** @var null|string */ |
||
| 168 | protected $_built_query = null; |
||
| 169 | |||
| 170 | // Make handlers public so whe can delete them externally to reduce memory in hhmv |
||
| 171 | //protected $_handlers = []; |
||
| 172 | public $_handlers = []; |
||
| 173 | |||
| 174 | /** @var bool User want to directly specify the fields */ |
||
| 175 | protected $_explicit_select_mode = false; |
||
| 176 | |||
| 177 | /** @var string[] */ |
||
| 178 | protected $_update_raw = []; |
||
| 179 | |||
| 180 | protected $_max_callback_failures = null; |
||
| 181 | |||
| 182 | protected $_num_callback_failures = 0; |
||
| 183 | |||
| 184 | protected $_filter_on_fetch = false; |
||
| 185 | |||
| 186 | protected $_log_filter_changes = true; |
||
| 187 | |||
| 188 | protected $_include_count = false; |
||
| 189 | |||
| 190 | /** |
||
| 191 | * @param AbstractPdo|null $connection |
||
| 192 | */ |
||
| 193 | public function __construct(AbstractPdo $connection=null) |
||
| 200 | |||
| 201 | public function init() |
||
| 203 | |||
| 204 | /** |
||
| 205 | * @return AbstractPdo |
||
| 206 | * @throws Exception |
||
| 207 | */ |
||
| 208 | public function getPdo() |
||
| 212 | |||
| 213 | /** |
||
| 214 | * @return AbstractLogger |
||
| 215 | */ |
||
| 216 | public function getLogger() |
||
| 220 | |||
| 221 | /** |
||
| 222 | * @return RedisCache |
||
| 223 | */ |
||
| 224 | public function getCache() |
||
| 228 | |||
| 229 | /** |
||
| 230 | * Define the working table and create a new instance |
||
| 231 | * |
||
| 232 | * @param string $tableName - Table name |
||
| 233 | * @param string $alias - The table alias name |
||
| 234 | * @param string $displayColumn |
||
| 235 | * @param string $primaryKeyName |
||
| 236 | * |
||
| 237 | * @return $this |
||
| 238 | */ |
||
| 239 | public function table($tableName, $alias='', $displayColumn='', $primaryKeyName='id') |
||
| 247 | |||
| 248 | /** |
||
| 249 | * @param $primaryKeyName |
||
| 250 | * @return $this |
||
| 251 | */ |
||
| 252 | public function primaryKeyName($primaryKeyName) |
||
| 257 | |||
| 258 | /** |
||
| 259 | * @param $tableName |
||
| 260 | * |
||
| 261 | * @return $this |
||
| 262 | */ |
||
| 263 | public function tableName($tableName) |
||
| 268 | |||
| 269 | /** |
||
| 270 | * @param $explicitSelect |
||
| 271 | * |
||
| 272 | * @return $this |
||
| 273 | */ |
||
| 274 | public function explicitSelectMode($explicitSelect=true) |
||
| 279 | |||
| 280 | /** |
||
| 281 | * @param bool $filterOnFetch |
||
| 282 | * |
||
| 283 | * @return $this |
||
| 284 | */ |
||
| 285 | public function filterOnFetch($filterOnFetch=true) |
||
| 290 | |||
| 291 | /** |
||
| 292 | * @param bool $logFilterChanges |
||
| 293 | * |
||
| 294 | * @return $this |
||
| 295 | */ |
||
| 296 | public function logFilterChanges($logFilterChanges=true) |
||
| 301 | |||
| 302 | /** |
||
| 303 | * Return the name of the table |
||
| 304 | * |
||
| 305 | * @return string |
||
| 306 | */ |
||
| 307 | public function getTableName() |
||
| 311 | |||
| 312 | /** |
||
| 313 | * @return string |
||
| 314 | */ |
||
| 315 | public function getDisplayColumn() |
||
| 319 | |||
| 320 | /** |
||
| 321 | * Set the display column |
||
| 322 | * |
||
| 323 | * @param string $column |
||
| 324 | * |
||
| 325 | * @return $this |
||
| 326 | */ |
||
| 327 | public function displayColumn($column) |
||
| 332 | /** |
||
| 333 | * Set the table alias |
||
| 334 | * |
||
| 335 | * @param string $alias |
||
| 336 | * |
||
| 337 | * @return $this |
||
| 338 | */ |
||
| 339 | public function tableAlias($alias) |
||
| 344 | |||
| 345 | /** |
||
| 346 | * @param int $cacheTtl |
||
| 347 | * @return $this |
||
| 348 | * @throws Exception |
||
| 349 | */ |
||
| 350 | protected function _cacheTtl($cacheTtl) |
||
| 360 | |||
| 361 | /** |
||
| 362 | * @return string |
||
| 363 | */ |
||
| 364 | public function getTableAlias() |
||
| 368 | |||
| 369 | /** |
||
| 370 | * @param array $associations |
||
| 371 | * |
||
| 372 | * @return $this |
||
| 373 | */ |
||
| 374 | public function associations(array $associations) |
||
| 379 | |||
| 380 | /** |
||
| 381 | * @param string $alias |
||
| 382 | * @param array $definition |
||
| 383 | * @return $this |
||
| 384 | */ |
||
| 385 | public function setBelongsTo($alias, array $definition) |
||
| 393 | |||
| 394 | public function setBelongsToDisplayField($alias, $displayField) |
||
| 403 | |||
| 404 | /** |
||
| 405 | * @param PDOStatement $stmt |
||
| 406 | * |
||
| 407 | * @param PDOStatement $stmt |
||
| 408 | * @param Closure $fnCallback |
||
| 409 | * @return bool|stdClass |
||
| 410 | */ |
||
| 411 | public function fetchRow(PDOStatement $stmt, Closure $fnCallback=null) |
||
| 430 | |||
| 431 | /** |
||
| 432 | * @param array $schema |
||
| 433 | * |
||
| 434 | * @return $this |
||
| 435 | */ |
||
| 436 | public function schema(array $schema) |
||
| 441 | |||
| 442 | /** |
||
| 443 | * @param string|array $field |
||
| 444 | * @param $type |
||
| 445 | * @return $this |
||
| 446 | */ |
||
| 447 | public function addSchema($field, $type) |
||
| 460 | |||
| 461 | /** |
||
| 462 | * @param $keys_only |
||
| 463 | * @return array |
||
| 464 | */ |
||
| 465 | public function getColumns($keys_only=true) |
||
| 469 | |||
| 470 | /** |
||
| 471 | * Get the primary key name |
||
| 472 | * |
||
| 473 | * @return string |
||
| 474 | */ |
||
| 475 | public function getPrimaryKeyName() |
||
| 479 | |||
| 480 | /** |
||
| 481 | * @param string $query |
||
| 482 | * @param array $parameters |
||
| 483 | * |
||
| 484 | * @return bool |
||
| 485 | * @throws Exception |
||
| 486 | */ |
||
| 487 | public function execute($query, array $parameters=[]) |
||
| 510 | |||
| 511 | /** |
||
| 512 | * @param string $query |
||
| 513 | * @param array $params |
||
| 514 | * @return $this |
||
| 515 | */ |
||
| 516 | public function query($query, array $params=[]) |
||
| 522 | |||
| 523 | /** |
||
| 524 | * @return bool |
||
| 525 | */ |
||
| 526 | public function begin() |
||
| 530 | |||
| 531 | /** |
||
| 532 | * @return bool |
||
| 533 | */ |
||
| 534 | public function commit() |
||
| 538 | |||
| 539 | /** |
||
| 540 | * @return bool |
||
| 541 | */ |
||
| 542 | public function rollback() |
||
| 547 | |||
| 548 | |||
| 549 | /** |
||
| 550 | * @param string $sql |
||
| 551 | * @param array $params |
||
| 552 | * |
||
| 553 | * @return string |
||
| 554 | */ |
||
| 555 | public function buildQuery($sql, array $params=[]) |
||
| 581 | |||
| 582 | /** |
||
| 583 | * @param stdClass $record |
||
| 584 | * |
||
| 585 | * @return stdClass |
||
| 586 | */ |
||
| 587 | protected function _trimAndLowerCaseKeys(stdClass $record) |
||
| 596 | |||
| 597 | /** |
||
| 598 | * Return the number of affected row by the last statement |
||
| 599 | * |
||
| 600 | * @return int |
||
| 601 | */ |
||
| 602 | public function rowCount() |
||
| 607 | |||
| 608 | /** |
||
| 609 | * @return PDOStatement |
||
| 610 | * @throws PDOException |
||
| 611 | */ |
||
| 612 | public function fetchStmt() |
||
| 620 | |||
| 621 | /** |
||
| 622 | * @param bool $build |
||
| 623 | * @return array |
||
| 624 | */ |
||
| 625 | public function fetchSqlQuery($build=false) |
||
| 634 | |||
| 635 | /** |
||
| 636 | * @param string $table_name |
||
| 637 | * @param bool $drop_if_exists |
||
| 638 | * @param array $indexes |
||
| 639 | * @return $this |
||
| 640 | * @throws Exception |
||
| 641 | */ |
||
| 642 | public function fetchIntoMemoryTable($table_name, $drop_if_exists=true, array $indexes=[]) |
||
| 663 | |||
| 664 | /** |
||
| 665 | * @param null $keyedOn |
||
| 666 | * @param int $cacheTtl |
||
| 667 | * @return \stdClass[]|null |
||
| 668 | */ |
||
| 669 | public function fetch($keyedOn=null, $cacheTtl=self::CACHE_NO) |
||
| 704 | |||
| 705 | protected function _parseWhereForPrimaryLookup() |
||
| 720 | |||
| 721 | /** |
||
| 722 | * @param string $cacheKey |
||
| 723 | * @param Closure $func |
||
| 724 | * @param int $cacheTtl - 0 for default ttl, -1 for no cache or int for custom ttl |
||
| 725 | * @return mixed|null |
||
| 726 | */ |
||
| 727 | protected function _cacheData($cacheKey, Closure $func, $cacheTtl=self::CACHE_DEFAULT) |
||
| 764 | |||
| 765 | /** |
||
| 766 | * @param string $cacheKey |
||
| 767 | * @return bool |
||
| 768 | */ |
||
| 769 | public function clearCache($cacheKey) |
||
| 773 | |||
| 774 | /** |
||
| 775 | * @param string|null $table |
||
| 776 | * @return bool |
||
| 777 | */ |
||
| 778 | public function clearCacheByTable($table=null) |
||
| 787 | |||
| 788 | /** |
||
| 789 | * @param Closure $fnCallback |
||
| 790 | * @param null $keyedOn |
||
| 791 | * @param bool $returnSuccessCnt |
||
| 792 | * @return stdClass[]|int |
||
| 793 | */ |
||
| 794 | public function fetchCallback(Closure $fnCallback, $keyedOn=null, $returnSuccessCnt=true) |
||
| 817 | |||
| 818 | /** |
||
| 819 | * @param $numFailures |
||
| 820 | * @return $this |
||
| 821 | */ |
||
| 822 | public function maxCallbackFailures($numFailures) |
||
| 828 | |||
| 829 | /** |
||
| 830 | * @param PDOStatement $stmt |
||
| 831 | * @param Closure $fnCallback |
||
| 832 | * @param int $successCnt |
||
| 833 | * @return bool|null|stdClass |
||
| 834 | */ |
||
| 835 | protected function _tallySuccessCount($stmt, Closure $fnCallback, &$successCnt) |
||
| 864 | |||
| 865 | /** |
||
| 866 | * @param null|string $keyedOn |
||
| 867 | * @param null|mixed $valueField |
||
| 868 | * @param int $cacheTtl |
||
| 869 | * @return mixed |
||
| 870 | */ |
||
| 871 | public function fetchList($keyedOn=null, $valueField=null, $cacheTtl=self::CACHE_NO) |
||
| 920 | |||
| 921 | /** |
||
| 922 | * @param string $column |
||
| 923 | * @param int $cacheTtl |
||
| 924 | * @param bool|true $unique |
||
| 925 | * @return array|mixed |
||
| 926 | */ |
||
| 927 | public function fetchColumn($column, $cacheTtl=self::CACHE_NO, $unique=true) |
||
| 936 | |||
| 937 | /** |
||
| 938 | * @param null|string $field |
||
| 939 | * @param null|int $itemId |
||
| 940 | * @param int $cacheTtl |
||
| 941 | * @return mixed|null |
||
| 942 | */ |
||
| 943 | public function fetchField($field=null, $itemId=null, $cacheTtl=self::CACHE_NO) |
||
| 965 | |||
| 966 | /** |
||
| 967 | * @param int|null $id |
||
| 968 | * @param int $cacheTtl |
||
| 969 | * @return \stdClass|bool |
||
| 970 | */ |
||
| 971 | public function fetchOne($id=null, $cacheTtl=self::CACHE_NO) |
||
| 981 | |||
| 982 | /** |
||
| 983 | * @param int|null $id |
||
| 984 | * @param int $cacheTtl |
||
| 985 | * @return \stdClass|bool |
||
| 986 | */ |
||
| 987 | public function fetchExists($id=null, $cacheTtl=self::CACHE_NO) |
||
| 995 | |||
| 996 | /*------------------------------------------------------------------------------ |
||
| 997 | Fluent Query Builder |
||
| 998 | *-----------------------------------------------------------------------------*/ |
||
| 999 | |||
| 1000 | /** |
||
| 1001 | * Create the select clause |
||
| 1002 | * |
||
| 1003 | * @param mixed $columns - the column to select. Can be string or array of fields |
||
| 1004 | * @param string $alias - an alias to the column |
||
| 1005 | * @param bool|true $explicitSelect |
||
| 1006 | * @return $this |
||
| 1007 | */ |
||
| 1008 | public function select($columns='*', $alias=null, $explicitSelect=true) |
||
| 1048 | |||
| 1049 | public function selectRaw($select) |
||
| 1054 | |||
| 1055 | /** |
||
| 1056 | * @param bool $log_queries |
||
| 1057 | * |
||
| 1058 | * @return $this |
||
| 1059 | */ |
||
| 1060 | public function logQueries($log_queries=true) |
||
| 1065 | |||
| 1066 | /** |
||
| 1067 | * @param bool $include_count |
||
| 1068 | * |
||
| 1069 | * @return $this |
||
| 1070 | */ |
||
| 1071 | public function includeCount($include_count=true) |
||
| 1076 | |||
| 1077 | /** |
||
| 1078 | * @param bool $distinct |
||
| 1079 | * |
||
| 1080 | * @return $this |
||
| 1081 | */ |
||
| 1082 | public function distinct($distinct=true) |
||
| 1087 | |||
| 1088 | /** |
||
| 1089 | * @param array $fields |
||
| 1090 | * @return $this |
||
| 1091 | */ |
||
| 1092 | public function withBelongsTo($fields=[]) |
||
| 1104 | |||
| 1105 | /** |
||
| 1106 | * @param string $alias |
||
| 1107 | * @param string $type |
||
| 1108 | * @param bool $addSelectField |
||
| 1109 | * @return $this |
||
| 1110 | */ |
||
| 1111 | public function autoJoin($alias, $type=self::LEFT_JOIN, $addSelectField=true) |
||
| 1127 | |||
| 1128 | /** |
||
| 1129 | * Add where condition, more calls appends with AND |
||
| 1130 | * |
||
| 1131 | * @param string $condition possibly containing ? or :name |
||
| 1132 | * @param mixed $parameters accepted by PDOStatement::execute or a scalar value |
||
| 1133 | * @param mixed ... |
||
| 1134 | * @return $this |
||
| 1135 | */ |
||
| 1136 | public function where($condition, $parameters = []) |
||
| 1183 | |||
| 1184 | /** |
||
| 1185 | * Create an AND operator in the where clause |
||
| 1186 | * |
||
| 1187 | * @return $this |
||
| 1188 | */ |
||
| 1189 | public function _and() |
||
| 1201 | |||
| 1202 | |||
| 1203 | /** |
||
| 1204 | * Create an OR operator in the where clause |
||
| 1205 | * |
||
| 1206 | * @return $this |
||
| 1207 | */ |
||
| 1208 | public function _or() |
||
| 1220 | |||
| 1221 | /** |
||
| 1222 | * To group multiple where clauses together. |
||
| 1223 | * |
||
| 1224 | * @return $this |
||
| 1225 | */ |
||
| 1226 | public function wrap() |
||
| 1235 | |||
| 1236 | /** |
||
| 1237 | * Where Primary key |
||
| 1238 | * |
||
| 1239 | * @param integer $id |
||
| 1240 | * @param bool $addAlias |
||
| 1241 | * |
||
| 1242 | * @return $this |
||
| 1243 | */ |
||
| 1244 | public function wherePk($id, $addAlias=true) |
||
| 1249 | |||
| 1250 | /** |
||
| 1251 | * WHERE $columnName != $value |
||
| 1252 | * |
||
| 1253 | * @param string $columnName |
||
| 1254 | * @param mixed $value |
||
| 1255 | * @return $this |
||
| 1256 | */ |
||
| 1257 | public function whereNot($columnName, $value) |
||
| 1261 | /** |
||
| 1262 | * WHERE $columnName != $value |
||
| 1263 | * |
||
| 1264 | * @param string $columnName |
||
| 1265 | * @param mixed $value |
||
| 1266 | * @return $this |
||
| 1267 | */ |
||
| 1268 | public function whereCoercedNot($columnName, $value) |
||
| 1272 | |||
| 1273 | /** |
||
| 1274 | * WHERE $columnName LIKE $value |
||
| 1275 | * |
||
| 1276 | * @param string $columnName |
||
| 1277 | * @param mixed $value |
||
| 1278 | * @return $this |
||
| 1279 | */ |
||
| 1280 | public function whereLike($columnName, $value) |
||
| 1284 | |||
| 1285 | /** |
||
| 1286 | * @param string $columnName |
||
| 1287 | * @param mixed $value1 |
||
| 1288 | * @param mixed $value2 |
||
| 1289 | * @return $this |
||
| 1290 | */ |
||
| 1291 | public function whereBetween($columnName, $value1, $value2) |
||
| 1295 | |||
| 1296 | /** |
||
| 1297 | * @param string $columnName |
||
| 1298 | * @param mixed $value1 |
||
| 1299 | * @param mixed $value2 |
||
| 1300 | * @return $this |
||
| 1301 | */ |
||
| 1302 | public function whereNotBetween($columnName, $value1, $value2) |
||
| 1306 | |||
| 1307 | /** |
||
| 1308 | * @param string $columnName |
||
| 1309 | * @param string $regex |
||
| 1310 | * @return $this |
||
| 1311 | */ |
||
| 1312 | public function whereRegex($columnName, $regex) |
||
| 1316 | |||
| 1317 | /** |
||
| 1318 | * @param string $columnName |
||
| 1319 | * @param string $regex |
||
| 1320 | * @return $this |
||
| 1321 | */ |
||
| 1322 | public function whereNotRegex($columnName, $regex) |
||
| 1326 | |||
| 1327 | /** |
||
| 1328 | * WHERE $columnName NOT LIKE $value |
||
| 1329 | * |
||
| 1330 | * @param string $columnName |
||
| 1331 | * @param mixed $value |
||
| 1332 | * @return $this |
||
| 1333 | */ |
||
| 1334 | public function whereNotLike($columnName, $value) |
||
| 1338 | |||
| 1339 | /** |
||
| 1340 | * WHERE $columnName > $value |
||
| 1341 | * |
||
| 1342 | * @param string $columnName |
||
| 1343 | * @param mixed $value |
||
| 1344 | * @return $this |
||
| 1345 | */ |
||
| 1346 | public function whereGt($columnName, $value) |
||
| 1350 | |||
| 1351 | /** |
||
| 1352 | * WHERE $columnName >= $value |
||
| 1353 | * |
||
| 1354 | * @param string $columnName |
||
| 1355 | * @param mixed $value |
||
| 1356 | * @return $this |
||
| 1357 | */ |
||
| 1358 | public function whereGte($columnName, $value) |
||
| 1362 | |||
| 1363 | /** |
||
| 1364 | * WHERE $columnName < $value |
||
| 1365 | * |
||
| 1366 | * @param string $columnName |
||
| 1367 | * @param mixed $value |
||
| 1368 | * @return $this |
||
| 1369 | */ |
||
| 1370 | public function whereLt($columnName, $value) |
||
| 1374 | |||
| 1375 | /** |
||
| 1376 | * WHERE $columnName <= $value |
||
| 1377 | * |
||
| 1378 | * @param string $columnName |
||
| 1379 | * @param mixed $value |
||
| 1380 | * @return $this |
||
| 1381 | */ |
||
| 1382 | public function whereLte($columnName, $value) |
||
| 1386 | |||
| 1387 | /** |
||
| 1388 | * WHERE $columnName IN (?,?,?,...) |
||
| 1389 | * |
||
| 1390 | * @param string $columnName |
||
| 1391 | * @param array $values |
||
| 1392 | * @return $this |
||
| 1393 | */ |
||
| 1394 | public function whereIn($columnName, array $values) |
||
| 1398 | |||
| 1399 | /** |
||
| 1400 | * WHERE $columnName NOT IN (?,?,?,...) |
||
| 1401 | * |
||
| 1402 | * @param string $columnName |
||
| 1403 | * @param array $values |
||
| 1404 | * @return $this |
||
| 1405 | */ |
||
| 1406 | public function whereNotIn($columnName, array $values) |
||
| 1411 | |||
| 1412 | /** |
||
| 1413 | * WHERE $columnName IS NULL |
||
| 1414 | * |
||
| 1415 | * @param string $columnName |
||
| 1416 | * @return $this |
||
| 1417 | */ |
||
| 1418 | public function whereNull($columnName) |
||
| 1422 | |||
| 1423 | /** |
||
| 1424 | * WHERE $columnName IS NOT NULL |
||
| 1425 | * |
||
| 1426 | * @param string $columnName |
||
| 1427 | * @return $this |
||
| 1428 | */ |
||
| 1429 | public function whereNotNull($columnName) |
||
| 1433 | |||
| 1434 | /** |
||
| 1435 | * @param string $statement |
||
| 1436 | * @param string $operator |
||
| 1437 | * @return $this |
||
| 1438 | */ |
||
| 1439 | public function having($statement, $operator = self::OPERATOR_AND) |
||
| 1447 | |||
| 1448 | /** |
||
| 1449 | * ORDER BY $columnName (ASC | DESC) |
||
| 1450 | * |
||
| 1451 | * @param string $columnName - The name of the column or an expression |
||
| 1452 | * @param string $ordering (DESC | ASC) |
||
| 1453 | * @return $this |
||
| 1454 | */ |
||
| 1455 | public function orderBy($columnName, $ordering=null) |
||
| 1466 | |||
| 1467 | /** |
||
| 1468 | * GROUP BY $columnName |
||
| 1469 | * |
||
| 1470 | * @param string $columnName |
||
| 1471 | * @return $this |
||
| 1472 | */ |
||
| 1473 | public function groupBy($columnName) |
||
| 1482 | |||
| 1483 | |||
| 1484 | /** |
||
| 1485 | * LIMIT $limit |
||
| 1486 | * |
||
| 1487 | * @param int $limit |
||
| 1488 | * @param int|null $offset |
||
| 1489 | * @return $this |
||
| 1490 | */ |
||
| 1491 | public function limit($limit, $offset=null) |
||
| 1500 | |||
| 1501 | /** |
||
| 1502 | * Return the limit |
||
| 1503 | * |
||
| 1504 | * @return integer |
||
| 1505 | */ |
||
| 1506 | public function getLimit() |
||
| 1510 | |||
| 1511 | /** |
||
| 1512 | * OFFSET $offset |
||
| 1513 | * |
||
| 1514 | * @param int $offset |
||
| 1515 | * @return $this |
||
| 1516 | */ |
||
| 1517 | public function offset($offset) |
||
| 1522 | |||
| 1523 | /** |
||
| 1524 | * Return the offset |
||
| 1525 | * |
||
| 1526 | * @return integer |
||
| 1527 | */ |
||
| 1528 | public function getOffset() |
||
| 1532 | |||
| 1533 | /** |
||
| 1534 | * Build a join |
||
| 1535 | * |
||
| 1536 | * @param string $table - The table name |
||
| 1537 | * @param string $constraint -> id = profile.user_id |
||
| 1538 | * @param string $tableAlias - The alias of the table name |
||
| 1539 | * @param string $joinOperator - LEFT | INNER | etc... |
||
| 1540 | * @return $this |
||
| 1541 | */ |
||
| 1542 | public function join($table, $constraint=null, $tableAlias = null, $joinOperator = '') |
||
| 1560 | |||
| 1561 | /** |
||
| 1562 | * Create a left join |
||
| 1563 | * |
||
| 1564 | * @param string $table |
||
| 1565 | * @param string $constraint |
||
| 1566 | * @param string $tableAlias |
||
| 1567 | * @return $this |
||
| 1568 | */ |
||
| 1569 | public function leftJoin($table, $constraint, $tableAlias=null) |
||
| 1573 | |||
| 1574 | |||
| 1575 | /** |
||
| 1576 | * Return the build select query |
||
| 1577 | * |
||
| 1578 | * @return string |
||
| 1579 | */ |
||
| 1580 | public function getSelectQuery() |
||
| 1622 | |||
| 1623 | /** |
||
| 1624 | * Prepare columns to include the table alias name |
||
| 1625 | * @param array $columns |
||
| 1626 | * @return array |
||
| 1627 | */ |
||
| 1628 | protected function _prepareColumns(array $columns) |
||
| 1657 | |||
| 1658 | /** |
||
| 1659 | * Build the WHERE clause(s) |
||
| 1660 | * |
||
| 1661 | * @param bool $purgeAliases |
||
| 1662 | * @return string |
||
| 1663 | */ |
||
| 1664 | protected function _getWhereString($purgeAliases=false) |
||
| 1696 | |||
| 1697 | /** |
||
| 1698 | * Return the HAVING clause |
||
| 1699 | * |
||
| 1700 | * @return string |
||
| 1701 | */ |
||
| 1702 | protected function _getHavingString() |
||
| 1720 | |||
| 1721 | /** |
||
| 1722 | * Return the values to be bound for where |
||
| 1723 | * |
||
| 1724 | * @param bool $purgeAliases |
||
| 1725 | * @return array |
||
| 1726 | */ |
||
| 1727 | protected function _getWhereParameters($purgeAliases=false) |
||
| 1732 | |||
| 1733 | /** |
||
| 1734 | * Insert new rows |
||
| 1735 | * $records can be a stdClass or an array of stdClass to add a bulk insert |
||
| 1736 | * If a single row is inserted, it will return it's row instance |
||
| 1737 | * |
||
| 1738 | * @param stdClass|array $records |
||
| 1739 | * @return int|stdClass|bool |
||
| 1740 | * @throws Exception |
||
| 1741 | */ |
||
| 1742 | public function insert($records) |
||
| 1772 | |||
| 1773 | /** |
||
| 1774 | * @param null $name |
||
| 1775 | * @return int |
||
| 1776 | */ |
||
| 1777 | public function getLastInsertId($name=null) |
||
| 1781 | |||
| 1782 | /** |
||
| 1783 | * @param $records |
||
| 1784 | * @return array |
||
| 1785 | */ |
||
| 1786 | public function insertSqlQuery($records) |
||
| 1806 | |||
| 1807 | /** |
||
| 1808 | * @param $data |
||
| 1809 | * @param array $matchOn |
||
| 1810 | * @param bool $returnObj |
||
| 1811 | * @return bool|int|stdClass |
||
| 1812 | */ |
||
| 1813 | public function upsert($data, array $matchOn=[], $returnObj=false) |
||
| 1834 | |||
| 1835 | /** |
||
| 1836 | * @param stdClass $object |
||
| 1837 | * @param array $matchOn |
||
| 1838 | * @param bool $returnObj |
||
| 1839 | * @return bool|int|stdClass |
||
| 1840 | */ |
||
| 1841 | public function upsertOne(stdClass $object, array $matchOn=[], $returnObj=false) |
||
| 1879 | |||
| 1880 | /** |
||
| 1881 | * @param array $data |
||
| 1882 | * @param array $matchOn |
||
| 1883 | * @param bool|false $returnObj |
||
| 1884 | * @return bool|int|stdClass |
||
| 1885 | */ |
||
| 1886 | public function upsertArr(array $data, array $matchOn=[], $returnObj=false) |
||
| 1890 | |||
| 1891 | /** |
||
| 1892 | * Update entries |
||
| 1893 | * Use the query builder to create the where clause |
||
| 1894 | * |
||
| 1895 | * @param stdClass $record |
||
| 1896 | * @param bool $updateAll |
||
| 1897 | * @return bool|int |
||
| 1898 | * @throws Exception |
||
| 1899 | */ |
||
| 1900 | public function update(stdClass $record, $updateAll=false) |
||
| 1922 | |||
| 1923 | /** |
||
| 1924 | * @param array $record |
||
| 1925 | * @param bool|false $updateAll |
||
| 1926 | * @return bool|int |
||
| 1927 | * @throws Exception |
||
| 1928 | */ |
||
| 1929 | public function updateArr(array $record, $updateAll=false) |
||
| 1933 | |||
| 1934 | /** |
||
| 1935 | * @param array $record |
||
| 1936 | * @return bool|int|stdClass |
||
| 1937 | */ |
||
| 1938 | public function insertArr(array $record) |
||
| 1942 | |||
| 1943 | /** |
||
| 1944 | * @param int $field |
||
| 1945 | * @param mixed $value |
||
| 1946 | * @param null $id |
||
| 1947 | * @param bool|false $updateAll |
||
| 1948 | * @return bool|int |
||
| 1949 | * @throws Exception |
||
| 1950 | */ |
||
| 1951 | public function updateField($field, $value, $id=null, $updateAll=false) |
||
| 1959 | |||
| 1960 | /** |
||
| 1961 | * @param int $field |
||
| 1962 | * @param mixed $value |
||
| 1963 | * @param null $id |
||
| 1964 | * @param bool|false $updateAll |
||
| 1965 | * @return bool|int |
||
| 1966 | * @throws Exception |
||
| 1967 | */ |
||
| 1968 | public function concatField($field, $value, $id=null, $updateAll=false) |
||
| 1972 | |||
| 1973 | /** |
||
| 1974 | * @param stdClass $record |
||
| 1975 | * @return bool|int |
||
| 1976 | * @throws Exception |
||
| 1977 | */ |
||
| 1978 | public function updateChanged(stdClass $record) |
||
| 1991 | |||
| 1992 | /** |
||
| 1993 | * @param string $expression |
||
| 1994 | * @param array $params |
||
| 1995 | * @return $this |
||
| 1996 | */ |
||
| 1997 | public function updateByExpression($expression, array $params) |
||
| 2002 | |||
| 2003 | /** |
||
| 2004 | * @param array $data |
||
| 2005 | * @return int |
||
| 2006 | * @throws Exception |
||
| 2007 | */ |
||
| 2008 | public function rawUpdate(array $data=[]) |
||
| 2016 | |||
| 2017 | /** |
||
| 2018 | * @param stdClass $record |
||
| 2019 | * @return array |
||
| 2020 | */ |
||
| 2021 | public function updateSqlQuery(stdClass $record) |
||
| 2031 | |||
| 2032 | /** |
||
| 2033 | * @param $record |
||
| 2034 | * @return array |
||
| 2035 | */ |
||
| 2036 | protected function updateSql(array $record) |
||
| 2066 | |||
| 2067 | /** |
||
| 2068 | * Delete rows |
||
| 2069 | * Use the query builder to create the where clause |
||
| 2070 | * @param bool $deleteAll = When there is no where condition, setting to true will delete all |
||
| 2071 | * @return int - total affected rows |
||
| 2072 | * @throws Exception |
||
| 2073 | */ |
||
| 2074 | public function delete($deleteAll=false) |
||
| 2084 | |||
| 2085 | /** |
||
| 2086 | * @param bool|false $force |
||
| 2087 | * @return $this |
||
| 2088 | * @throws Exception |
||
| 2089 | */ |
||
| 2090 | public function truncate($force=false) |
||
| 2103 | |||
| 2104 | /** |
||
| 2105 | * @return array |
||
| 2106 | */ |
||
| 2107 | public function deleteSqlQuery() |
||
| 2117 | |||
| 2118 | |||
| 2119 | /** |
||
| 2120 | * Return the aggregate count of column |
||
| 2121 | * |
||
| 2122 | * @param string $column |
||
| 2123 | * @param int $cacheTtl |
||
| 2124 | * @return int |
||
| 2125 | */ |
||
| 2126 | public function count($column='*', $cacheTtl=self::CACHE_NO) |
||
| 2133 | |||
| 2134 | |||
| 2135 | /** |
||
| 2136 | * Return the aggregate max count of column |
||
| 2137 | * |
||
| 2138 | * @param string $column |
||
| 2139 | * @param int $cacheTtl |
||
| 2140 | * @return mixed|null |
||
| 2141 | */ |
||
| 2142 | public function max($column, $cacheTtl=self::CACHE_NO) |
||
| 2149 | |||
| 2150 | |||
| 2151 | /** |
||
| 2152 | * Return the aggregate min count of column |
||
| 2153 | * |
||
| 2154 | * @param string $column |
||
| 2155 | * @param int $cacheTtl |
||
| 2156 | * @return mixed|null |
||
| 2157 | */ |
||
| 2158 | public function min($column, $cacheTtl=self::CACHE_NO) |
||
| 2165 | |||
| 2166 | /** |
||
| 2167 | * Return the aggregate sum count of column |
||
| 2168 | * |
||
| 2169 | * @param string $column |
||
| 2170 | * @param int $cacheTtl |
||
| 2171 | * @return mixed|null |
||
| 2172 | */ |
||
| 2173 | public function sum($column, $cacheTtl=self::CACHE_NO) |
||
| 2180 | |||
| 2181 | /** |
||
| 2182 | * Return the aggregate average count of column |
||
| 2183 | * |
||
| 2184 | * @param string $column |
||
| 2185 | * @param int $cacheTtl |
||
| 2186 | * @return mixed|null |
||
| 2187 | */ |
||
| 2188 | public function avg($column, $cacheTtl=self::CACHE_NO) |
||
| 2195 | |||
| 2196 | /*******************************************************************************/ |
||
| 2197 | // Utilities methods |
||
| 2198 | |||
| 2199 | /** |
||
| 2200 | * Reset fields |
||
| 2201 | * |
||
| 2202 | * @return $this |
||
| 2203 | */ |
||
| 2204 | public function reset() |
||
| 2231 | |||
| 2232 | /** |
||
| 2233 | * Return a YYYY-MM-DD HH:II:SS date format |
||
| 2234 | * |
||
| 2235 | * @param string $datetime - An english textual datetime description |
||
| 2236 | * now, yesterday, 3 days ago, +1 week |
||
| 2237 | * http://php.net/manual/en/function.strtotime.php |
||
| 2238 | * @return string YYYY-MM-DD HH:II:SS |
||
| 2239 | */ |
||
| 2240 | public static function NOW($datetime = 'now') |
||
| 2244 | |||
| 2245 | /** |
||
| 2246 | * Return a string containing the given number of question marks, |
||
| 2247 | * separated by commas. Eg '?, ?, ?' |
||
| 2248 | * |
||
| 2249 | * @param int - total of placeholder to insert |
||
| 2250 | * @return string |
||
| 2251 | */ |
||
| 2252 | protected function _makePlaceholders($number_of_placeholders=1) |
||
| 2256 | |||
| 2257 | /** |
||
| 2258 | * Format the table{Primary|Foreign}KeyName |
||
| 2259 | * |
||
| 2260 | * @param string $pattern |
||
| 2261 | * @param string $tableName |
||
| 2262 | * @return string |
||
| 2263 | */ |
||
| 2264 | protected function _formatKeyName($pattern, $tableName) |
||
| 2268 | |||
| 2269 | /** |
||
| 2270 | * @param string $query |
||
| 2271 | * @param array $parameters |
||
| 2272 | * |
||
| 2273 | * @return array |
||
| 2274 | */ |
||
| 2275 | protected function _logQuery($query, array $parameters) |
||
| 2287 | |||
| 2288 | /** |
||
| 2289 | * @param $ident |
||
| 2290 | * @param $builtQuery |
||
| 2291 | */ |
||
| 2292 | protected function _logSlowQueries($ident, $builtQuery) |
||
| 2305 | |||
| 2306 | /** |
||
| 2307 | * @return float |
||
| 2308 | */ |
||
| 2309 | public function getTimeTaken() |
||
| 2314 | |||
| 2315 | /** |
||
| 2316 | * @param $secs |
||
| 2317 | * @return $this |
||
| 2318 | */ |
||
| 2319 | public function slowQuerySeconds($secs) |
||
| 2325 | |||
| 2326 | |||
| 2327 | /** |
||
| 2328 | * @param $field |
||
| 2329 | * @param array $values |
||
| 2330 | * @param null $placeholder_prefix |
||
| 2331 | * |
||
| 2332 | * @return array |
||
| 2333 | */ |
||
| 2334 | public function getNamedWhereIn($field, array $values, $placeholder_prefix=null) |
||
| 2355 | |||
| 2356 | /** |
||
| 2357 | * @param $field |
||
| 2358 | * @param string $delimiter |
||
| 2359 | * |
||
| 2360 | * @return array |
||
| 2361 | */ |
||
| 2362 | protected function _getColumnAliasParts($field, $delimiter=':') |
||
| 2371 | |||
| 2372 | /** |
||
| 2373 | * @param string $column |
||
| 2374 | * @param string $term |
||
| 2375 | * @return $this |
||
| 2376 | */ |
||
| 2377 | protected function _addWhereClause($column, $term) |
||
| 2433 | |||
| 2434 | public function destroy() |
||
| 2443 | |||
| 2444 | public function __destruct() |
||
| 2448 | |||
| 2449 | /** @var string */ |
||
| 2450 | static protected $_model_namespace = ''; |
||
| 2451 | |||
| 2452 | /** @var bool */ |
||
| 2453 | protected $_validation_exceptions = true; |
||
| 2454 | |||
| 2455 | /** @var array */ |
||
| 2456 | protected $_paging_meta = []; |
||
| 2457 | |||
| 2458 | /** @var int */ |
||
| 2459 | protected $_default_max = 100; |
||
| 2460 | |||
| 2461 | /** |
||
| 2462 | * Load a model |
||
| 2463 | * |
||
| 2464 | * @param string $model_name |
||
| 2465 | * @param AbstractPdo $connection |
||
| 2466 | * @return Model |
||
| 2467 | * @throws ModelNotFoundException |
||
| 2468 | */ |
||
| 2469 | public static function loadModel($model_name, AbstractPdo $connection=null) |
||
| 2478 | |||
| 2479 | /** |
||
| 2480 | * Load a model |
||
| 2481 | * |
||
| 2482 | * @param string $table_name |
||
| 2483 | * @param AbstractPdo $connection |
||
| 2484 | * @return $this |
||
| 2485 | */ |
||
| 2486 | public static function loadTable($table_name, AbstractPdo $connection=null) |
||
| 2492 | |||
| 2493 | /** |
||
| 2494 | * @param string $columnName |
||
| 2495 | * @param int $cacheTtl |
||
| 2496 | * @param bool $flushCache |
||
| 2497 | * @return bool |
||
| 2498 | */ |
||
| 2499 | public function columnExists($columnName, $cacheTtl=self::CACHE_NO, $flushCache=false) |
||
| 2504 | |||
| 2505 | /** |
||
| 2506 | * @param int $cacheTtl |
||
| 2507 | * @param bool $flushCache |
||
| 2508 | * @return $this |
||
| 2509 | */ |
||
| 2510 | public function loadSchemaFromDb($cacheTtl=self::CACHE_NO, $flushCache=false) |
||
| 2516 | |||
| 2517 | /** |
||
| 2518 | * @param int $cacheTtl |
||
| 2519 | * @param bool $flushCache |
||
| 2520 | * @return array |
||
| 2521 | * @throws \Terah\Assert\AssertionFailedException |
||
| 2522 | */ |
||
| 2523 | public function getSchemaFromDb($cacheTtl=self::CACHE_NO, $flushCache=false) |
||
| 2535 | |||
| 2536 | /** |
||
| 2537 | * @param string $table |
||
| 2538 | * @param int $cacheTtl |
||
| 2539 | * @param bool $flushCache |
||
| 2540 | * @return array |
||
| 2541 | */ |
||
| 2542 | protected function _getColumnsByTableFromDb($table, $cacheTtl=self::CACHE_NO, $flushCache=false) |
||
| 2557 | |||
| 2558 | /** |
||
| 2559 | * @param string $table |
||
| 2560 | * @return bool |
||
| 2561 | */ |
||
| 2562 | public function clearSchemaCache($table) |
||
| 2566 | |||
| 2567 | /** |
||
| 2568 | * @param stdClass $record |
||
| 2569 | * @return stdClass |
||
| 2570 | */ |
||
| 2571 | public function onFetch(stdClass $record) |
||
| 2580 | |||
| 2581 | /** |
||
| 2582 | * @param stdClass $record |
||
| 2583 | * @return stdClass |
||
| 2584 | */ |
||
| 2585 | public function cleanseRecord(stdClass $record) |
||
| 2601 | |||
| 2602 | /** |
||
| 2603 | * @param stdClass $record |
||
| 2604 | * @param string $type |
||
| 2605 | * @return stdClass |
||
| 2606 | */ |
||
| 2607 | public function beforeSave(stdClass $record, $type) |
||
| 2615 | |||
| 2616 | /** |
||
| 2617 | * @param stdClass $record |
||
| 2618 | * @param string $type |
||
| 2619 | * @return stdClass |
||
| 2620 | */ |
||
| 2621 | public function afterSave(stdClass $record, $type) |
||
| 2627 | |||
| 2628 | /** |
||
| 2629 | * @param stdClass $record |
||
| 2630 | * @param string $type |
||
| 2631 | * @return stdClass |
||
| 2632 | */ |
||
| 2633 | public function addDefaultFields(stdClass $record, $type) |
||
| 2638 | |||
| 2639 | public function applyGlobalModifiers(stdClass $record, $type) |
||
| 2644 | |||
| 2645 | public function removeUnneededFields(\stdClass $record, $type) |
||
| 2663 | |||
| 2664 | /** |
||
| 2665 | * @param array $data |
||
| 2666 | * @param string $saveType |
||
| 2667 | * @return array |
||
| 2668 | */ |
||
| 2669 | public function cleanseWebData($data, $saveType) |
||
| 2683 | |||
| 2684 | /** |
||
| 2685 | * @return array |
||
| 2686 | */ |
||
| 2687 | public function skeleton() |
||
| 2697 | |||
| 2698 | |||
| 2699 | /** |
||
| 2700 | * @return Closure[] |
||
| 2701 | */ |
||
| 2702 | protected function _getFieldHandlers() |
||
| 2706 | |||
| 2707 | /** |
||
| 2708 | * @param bool $toString |
||
| 2709 | * @return array|string |
||
| 2710 | */ |
||
| 2711 | public function getErrors($toString=false) |
||
| 2724 | |||
| 2725 | /** |
||
| 2726 | * @param bool $throw |
||
| 2727 | * @return $this |
||
| 2728 | */ |
||
| 2729 | public function validationExceptions($throw=true) |
||
| 2734 | |||
| 2735 | /** |
||
| 2736 | * @param array $query array('_limit' => int, '_offset' => int, '_order' => string, '_fields' => string, _search) |
||
| 2737 | * |
||
| 2738 | * @return $this |
||
| 2739 | * @throws Exception |
||
| 2740 | */ |
||
| 2741 | public function paginate(array $query=[]) |
||
| 2750 | |||
| 2751 | /** |
||
| 2752 | * @param null|string $limit |
||
| 2753 | * @param null|string|int $offset |
||
| 2754 | * @return $this |
||
| 2755 | */ |
||
| 2756 | protected function _setLimit($limit=null, $offset=null) |
||
| 2770 | |||
| 2771 | /** |
||
| 2772 | * @param null|string|array $fields |
||
| 2773 | * @return $this |
||
| 2774 | * @throws Exception |
||
| 2775 | */ |
||
| 2776 | protected function _setFields($fields=null) |
||
| 2823 | |||
| 2824 | /** |
||
| 2825 | * @param null|string $orderBy |
||
| 2826 | * @return $this|FluentPdoModel |
||
| 2827 | */ |
||
| 2828 | protected function _setOrderBy($orderBy=null) |
||
| 2863 | |||
| 2864 | /** |
||
| 2865 | * @param null $type |
||
| 2866 | * @return array |
||
| 2867 | */ |
||
| 2868 | public function getPagingMeta($type=null) |
||
| 2876 | |||
| 2877 | /** |
||
| 2878 | * @return $this |
||
| 2879 | */ |
||
| 2880 | public function setPagingMeta() |
||
| 2901 | |||
| 2902 | /** |
||
| 2903 | * Take a web request and format a query |
||
| 2904 | * |
||
| 2905 | * @param array $query |
||
| 2906 | * |
||
| 2907 | * @return $this |
||
| 2908 | * @throws Exception |
||
| 2909 | */ |
||
| 2910 | public function filter(array $query=[]) |
||
| 2975 | |||
| 2976 | /** |
||
| 2977 | * @param string $column |
||
| 2978 | * @param $displayCol |
||
| 2979 | * @return string|null |
||
| 2980 | */ |
||
| 2981 | protected function _findFieldByQuery($column, $displayCol) |
||
| 3026 | |||
| 3027 | public function getSearchableAssociations() |
||
| 3032 | |||
| 3033 | /** |
||
| 3034 | * @param $keys_only |
||
| 3035 | * @return array |
||
| 3036 | */ |
||
| 3037 | |||
| 3038 | public function columns($keys_only=true) |
||
| 3042 | |||
| 3043 | /** |
||
| 3044 | * @param string $field |
||
| 3045 | * @param mixed $value |
||
| 3046 | * @param bool|false $permissive |
||
| 3047 | * @return float|int|null|string |
||
| 3048 | */ |
||
| 3049 | protected function _fixType($field, $value, $permissive=false) |
||
| 3088 | |||
| 3089 | /** |
||
| 3090 | * @param stdClass $record |
||
| 3091 | * @param string $type |
||
| 3092 | * @return stdClass |
||
| 3093 | */ |
||
| 3094 | public function fixTypes(stdClass $record, $type=null) |
||
| 3107 | |||
| 3108 | /** |
||
| 3109 | * @param stdClass $record |
||
| 3110 | * @param string $type |
||
| 3111 | * @return stdClass |
||
| 3112 | * @throws Exception |
||
| 3113 | */ |
||
| 3114 | public function applyHandlers(stdClass $record, $type='INSERT') |
||
| 3141 | |||
| 3142 | /** |
||
| 3143 | * @param string $field |
||
| 3144 | * @param mixed $value |
||
| 3145 | * @param null $type |
||
| 3146 | * @param null $record |
||
| 3147 | * @return null |
||
| 3148 | * @throws Exception |
||
| 3149 | */ |
||
| 3150 | protected function applyHandler($field, $value, $type=null, $record=null) |
||
| 3172 | |||
| 3173 | protected function _compileHandlers() |
||
| 3181 | } |
||
| 3182 | |||
| 3210 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.