You are here

function DB_common::query in Flickr API 5

Sends a query to the database server

The query string can be either a normal statement to be sent directly to the server OR if <var>$params</var> are passed the query can have placeholders and it will be passed through prepare() and execute().

Parameters

string $query the SQL query or the statement to prepare:

mixed $params 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.

See also

DB_result, DB_common::prepare(), DB_common::execute()

13 calls to DB_common::query()
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
DB_common::getOne in phpFlickr/PEAR/DB/common.php
Fetches the first column of the first row from a query result
DB_common::getRow in phpFlickr/PEAR/DB/common.php
Fetches the first row of data returned from a query result

... See full list

File

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

Class

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

Code

function &query($query, $params = []) {
  if (sizeof($params) > 0) {
    $sth = $this
      ->prepare($query);
    if (DB::isError($sth)) {
      return $sth;
    }
    $ret =& $this
      ->execute($sth, $params);
    $this
      ->freePrepared($sth, false);
    return $ret;
  }
  else {
    $this->last_parameters = array();
    $result = $this
      ->simpleQuery($query);
    if ($result === DB_OK || DB::isError($result)) {
      return $result;
    }
    else {
      $tmp =& new DB_result($this, $result);
      return $tmp;
    }
  }
}