Conditions | 5 |
Paths | 5 |
Total Lines | 23 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function exists($params, $condition = 'AND') |
||
18 | { |
||
19 | if (empty($params)) { |
||
20 | return false; |
||
21 | } |
||
22 | |||
23 | $query = 'SELECT Id, Name, Email, UserType, UserRoleId FROM ' . $this->getType() . ' WHERE '; |
||
24 | |||
25 | $paramsWithKeys = []; |
||
26 | foreach ($params as $fieldName => $fieldValue) { |
||
27 | $paramsWithKeys[] = $fieldName . ' = \'' . addslashes(trim($fieldValue)) . '\''; |
||
28 | } |
||
29 | |||
30 | $query .= '(' . implode(' ' . $condition . ' ', $paramsWithKeys) . ')'; |
||
31 | |||
32 | $response = $this->query($query); |
||
33 | |||
34 | if ($response && $response->totalSize > 0) { |
||
35 | return array_shift($response->records); |
||
36 | } |
||
37 | |||
38 | return false; |
||
39 | } |
||
40 | |||
42 |