| Conditions | 4 |
| Paths | 9 |
| Total Lines | 18 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | public function findByField(array $fields, $options = []) { |
||
| 23 | $cacheId = md5(serialize(func_get_args())); |
||
| 24 | if (!isset($this->resultCache[$cacheId])) { |
||
| 25 | $query = $this->whereBuilder->createSql($fields); |
||
| 26 | |||
| 27 | if (!isset($options['order'])) $options['order'] = $this->defaultSort; |
||
| 28 | |||
| 29 | try { |
||
| 30 | $this->resultCache[$cacheId] = $this->selectQuery($this->selectBuilder->select($this->table, $query['sql'], $query['args'], $options)); |
||
| 31 | $this->databaseModify->addIndex(array_keys($query['args'])); |
||
| 32 | $this->databaseModify->addIndex(explode(',', $options['order'])); |
||
| 33 | } |
||
| 34 | catch (\Exception $e) { |
||
| 35 | $this->errors[] = $e; |
||
|
|
|||
| 36 | $this->resultCache[$cacheId] = []; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | return $this->resultCache[$cacheId]; |
||
| 40 | } |
||
| 50 |