| Total Complexity | 11 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class QueryHelpers |
||
| 8 | { |
||
| 9 | |||
| 10 | |||
| 11 | public static function bind(\PDOStatement &$stmt, array $params = []) |
||
| 12 | { |
||
| 13 | $defaultType = \PDO::PARAM_STR; |
||
| 14 | |||
| 15 | foreach ($params as $key => $value) { |
||
| 16 | $type = $defaultType; |
||
| 17 | |||
| 18 | if (is_int($value)) { |
||
| 19 | $type = \PDO::PARAM_INT; |
||
| 20 | } |
||
| 21 | |||
| 22 | if (is_resource($value)) { |
||
| 23 | $type = \PDO::PARAM_LOB; |
||
| 24 | } |
||
| 25 | |||
| 26 | if (is_bool($value)) { |
||
| 27 | $type = \PDO::PARAM_BOOL; |
||
| 28 | } |
||
| 29 | |||
| 30 | $stmt->bindValue( |
||
| 31 | is_string($key) ? $key : $key + 1, |
||
| 32 | $value, |
||
| 33 | $type |
||
| 34 | ); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | public static function dynamicQueryFilters(array &$queryParams, string $queryString, array $bind) |
||
| 58 | } |
||
| 59 | |||
| 60 | } |