| @@ 151-166 (lines=16) @@ | ||
| 148 | ||
| 149 | // get names wheres |
|
| 150 | $names_where = ''; |
|
| 151 | if ($names !== null) { |
|
| 152 | if (!is_array($names)) { |
|
| 153 | $names = array($names); |
|
| 154 | } |
|
| 155 | ||
| 156 | $sanitised_names = array(); |
|
| 157 | foreach ($names as $name) { |
|
| 158 | $name = $name_prefix . $name; |
|
| 159 | $sanitised_names[] = '\'' . $this->db->sanitizeString($name) . '\''; |
|
| 160 | } |
|
| 161 | ||
| 162 | $names_str = implode(',', $sanitised_names); |
|
| 163 | if ($names_str) { |
|
| 164 | $names_where = "(ps.name IN ($names_str))"; |
|
| 165 | } |
|
| 166 | } |
|
| 167 | ||
| 168 | // get values wheres |
|
| 169 | $values_where = ''; |
|
| @@ 170-188 (lines=19) @@ | ||
| 167 | ||
| 168 | // get values wheres |
|
| 169 | $values_where = ''; |
|
| 170 | if ($values !== null) { |
|
| 171 | if (!is_array($values)) { |
|
| 172 | $values = array($values); |
|
| 173 | } |
|
| 174 | ||
| 175 | $sanitised_values = array(); |
|
| 176 | foreach ($values as $value) { |
|
| 177 | // normalize to 0 |
|
| 178 | if (!$value) { |
|
| 179 | $value = 0; |
|
| 180 | } |
|
| 181 | $sanitised_values[] = '\'' . $this->db->sanitizeString($value) . '\''; |
|
| 182 | } |
|
| 183 | ||
| 184 | $values_str = implode(',', $sanitised_values); |
|
| 185 | if ($values_str) { |
|
| 186 | $values_where = "(ps.value IN ($values_str))"; |
|
| 187 | } |
|
| 188 | } |
|
| 189 | ||
| 190 | if ($names_where && $values_where) { |
|
| 191 | $wheres[] = "($names_where AND $values_where)"; |
|