︙ | | | ︙ | |
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
reset($args);
if (is_int(key($args)))
{
foreach ($args as $i=>$arg)
{
$type = $this->getArgType($arg, $i+1);
$statement->bindValue((int)$i+1, $arg, $type);
}
}
else
{
foreach ($args as $key=>$value)
{
if (is_int($key))
{
throw new \InvalidArgumentException(__FUNCTION__ . ' requires argument to be a named-associative array, but key '.$key.' is an integer.');
}
$type = $this->getArgType($value, $key);
$statement->bindValue(':'.$key, $value, $type);
}
}
}
|
>
>
>
>
>
|
|
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
reset($args);
if (is_int(key($args)))
{
foreach ($args as $i=>$arg)
{
if (is_string($i))
{
throw new \InvalidArgumentException(sprintf('%s requires argument to be a keyed array, but key %s is a string.', __FUNCTION__, $i));
}
$type = $this->getArgType($arg, $i+1);
$statement->bindValue((int)$i+1, $arg, $type);
}
}
else
{
foreach ($args as $key=>$value)
{
if (is_int($key))
{
throw new \InvalidArgumentException(sprintf('%s requires argument to be a named-associative array, but key %s is an integer.', __FUNCTION__, $key));
}
$type = $this->getArgType($value, $key);
$statement->bindValue(':'.$key, $value, $type);
}
}
}
|
︙ | | | ︙ | |
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
{
throw new \RuntimeException($e->getMessage() . "\n" . $query . "\n" . json_encode($args, true));
}
}
public function get($query)
{
$args = array_slice(func_get_args(), 2);
return $this->fetch($this->query($query, $args), self::OBJ);
}
public function getAssoc($query)
{
$args = array_slice(func_get_args(), 1);
return $this->fetchAssoc($this->query($query, $args));
}
public function getAssocKey($query)
{
$args = array_slice(func_get_args(), 2);
return $this->fetchAssocKey($this->query($query, $args), self::OBJ);
}
public function insert($table, Array $fields)
{
$fields_names = array_keys($fields);
$query = sprintf('INSERT INTO %s (%s) VALUES (:%s);', $table,
|
|
|
|
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
{
throw new \RuntimeException($e->getMessage() . "\n" . $query . "\n" . json_encode($args, true));
}
}
public function get($query)
{
$args = array_slice(func_get_args(), 1);
return $this->fetch($this->query($query, $args), self::OBJ);
}
public function getAssoc($query)
{
$args = array_slice(func_get_args(), 1);
return $this->fetchAssoc($this->query($query, $args));
}
public function getAssocKey($query)
{
$args = array_slice(func_get_args(), 1);
return $this->fetchAssocKey($this->query($query, $args), self::OBJ);
}
public function insert($table, Array $fields)
{
$fields_names = array_keys($fields);
$query = sprintf('INSERT INTO %s (%s) VALUES (:%s);', $table,
|
︙ | | | ︙ | |
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
}
$args = array_slice(func_get_args(), 3);
$column_updates = [];
foreach ($fields as $key=>$value)
{
$key = 'field_' . $key;
// Append to arguments
$args[$key] = $value;
$column_updates[] = sprintf('%s = :%s', $key, $key);
}
$column_updates = implode(', ', $column_updates);
$query = sprintf('UPDATE %s SET %s WHERE %s;', $table, $column_updates, $where);
return $this->query($query, $args);
}
|
<
<
|
|
|
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
}
$args = array_slice(func_get_args(), 3);
$column_updates = [];
foreach ($fields as $key=>$value)
{
// Append to arguments
$args['field_' . $key] = $value;
$column_updates[] = sprintf('%s = :field_%s', $key, $key);
}
$column_updates = implode(', ', $column_updates);
$query = sprintf('UPDATE %s SET %s WHERE %s;', $table, $column_updates, $where);
return $this->query($query, $args);
}
|
︙ | | | ︙ | |
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
public function exec($query)
{
return $this->query($query, array_slice(func_get_args(), 1));
}
public function first($query)
{
$res = $this->query($query, array_slice(func_get_args(), 2));
$row = $res->fetchArray($all_columns ? SQLITE3_ASSOC : SQLITE3_NUM);
$res->finalize();
return is_array($row) ? (object) $row : false;
}
public function firstColumn($query)
{
|
|
|
|
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
public function exec($query)
{
return $this->query($query, array_slice(func_get_args(), 1));
}
public function first($query)
{
$res = $this->query($query, array_slice(func_get_args(), 1));
$row = $res->fetchArray(SQLITE3_ASSOC);
$res->finalize();
return is_array($row) ? (object) $row : false;
}
public function firstColumn($query)
{
|
︙ | | | ︙ | |