You are here

function DB_common::autoExecute in Flickr API 5

Automaticaly generates an insert or update query and call prepare() and execute() with it

@uses DB_common::autoPrepare(), DB_common::execute()

Parameters

string $table the table name:

array $fields_values the associative array where $key is a: field name and $value its value

int $mode a type of query to make:: DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE

string $where for update queries: the WHERE clause to: append to the SQL statement. Don't include the "WHERE" keyword.

Return value

mixed a new DB_result object for successful SELECT queries or DB_OK for successul data manipulation queries. A DB_Error object on failure.

File

phpFlickr/PEAR/DB/common.php, line 831

Class

DB_common
DB_common is the base class from which each database driver class extends

Code

function autoExecute($table, $fields_values, $mode = DB_AUTOQUERY_INSERT, $where = false) {
  $sth = $this
    ->autoPrepare($table, array_keys($fields_values), $mode, $where);
  if (DB::isError($sth)) {
    return $sth;
  }
  $ret =& $this
    ->execute($sth, array_values($fields_values));
  $this
    ->freePrepared($sth);
  return $ret;
}