@@ 52-58 (lines=7) @@ | ||
49 | * @param array where clause |
|
50 | * @return string |
|
51 | */ |
|
52 | public function update($table, $values, $where) |
|
53 | { |
|
54 | foreach ($values as $key => $val) { |
|
55 | $valstr[] = $this->escape_column($key).' = '.$val; |
|
56 | } |
|
57 | return 'UPDATE '.$this->escape_table($table).' SET '.implode(', ', $valstr).' WHERE '.implode(' ', $where); |
|
58 | } |
|
59 | ||
60 | /** |
|
61 | * Set the charset using 'SET NAMES <charset>'. |
|
@@ 215-222 (lines=8) @@ | ||
212 | * @param array values |
|
213 | * @return string |
|
214 | */ |
|
215 | public function insert($table, $keys, $values) |
|
216 | { |
|
217 | // Escape the column names |
|
218 | foreach ($keys as $key => $value) { |
|
219 | $keys[$key] = $this->escape_column($value); |
|
220 | } |
|
221 | return 'INSERT INTO '.$this->escape_table($table).' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; |
|
222 | } |
|
223 | ||
224 | /** |
|
225 | * Builds a MERGE portion of a query. |
@@ 188-195 (lines=8) @@ | ||
185 | return $prefix.' '.$this->escape_column($field).' NOT REGEXP \''.$this->escape_str($match) . '\''; |
|
186 | } |
|
187 | ||
188 | public function merge($table, $keys, $values) |
|
189 | { |
|
190 | // Escape the column names |
|
191 | foreach ($keys as $key => $value) { |
|
192 | $keys[$key] = $this->escape_column($value); |
|
193 | } |
|
194 | return 'REPLACE INTO '.$this->escape_table($table).' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; |
|
195 | } |
|
196 | ||
197 | public function limit($limit, $offset = 0) |
|
198 | { |