You are here

function DB_common::execute in Flickr API 5

Executes a DB statement prepared with prepare()

Example 1. <code> $sth = $db->prepare('INSERT INTO tbl (a, b, c) VALUES (?, !, &)'); $data = array( "John's text", "'it''s good'", 'filename.txt' ); $res =& $db->execute($sth, $data); </code>

Parameters

resource $stmt a DB statement resource returned from prepare():

mixed $data array, string or numeric data to be used in: execution of the statement. Quantity of items passed must match quantity of placeholders in query: meaning 1 placeholder for non-array parameters or 1 placeholder per array element.

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.

{@internal ibase and oci8 have their own execute() methods.}}

See also

DB_common::prepare()

8 calls to DB_common::execute()
DB_common::autoExecute in phpFlickr/PEAR/DB/common.php
Automaticaly generates an insert or update query and call prepare() and execute() with it
DB_common::executeMultiple in phpFlickr/PEAR/DB/common.php
Performs several execute() calls on the same statement handle
DB_common::getAll in phpFlickr/PEAR/DB/common.php
Fetches all of the rows from a query result
DB_common::getAssoc in phpFlickr/PEAR/DB/common.php
Fetches an entire query result and returns it as an associative array using the first column as the key
DB_common::getCol in phpFlickr/PEAR/DB/common.php
Fetches a single column from a query result and returns it as an indexed array

... See full list

File

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

Class

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

Code

function &execute($stmt, $data = []) {
  $realquery = $this
    ->executeEmulateQuery($stmt, $data);
  if (DB::isError($realquery)) {
    return $realquery;
  }
  $result = $this
    ->simpleQuery($realquery);
  if ($result === DB_OK || DB::isError($result)) {
    return $result;
  }
  else {
    $tmp =& new DB_result($this, $result);
    return $tmp;
  }
}