You are here

function DB_mysql::simpleQuery in Flickr API 5

Sends a query to the database server

Generally uses mysql_query(). If you want to use mysql_unbuffered_query() set the "result_buffering" option to 0 using setOptions(). This option was added in Release 1.7.0.

Parameters

string the SQL query string:

Return value

mixed + a PHP result resrouce for successful SELECT queries + the DB_OK constant for other successful queries + a DB_Error object on failure

File

phpFlickr/PEAR/DB/mysql.php, line 297

Class

DB_mysql
The methods PEAR DB uses to interact with PHP's mysql extension for interacting with MySQL databases

Code

function simpleQuery($query) {
  $ismanip = DB::isManip($query);
  $this->last_query = $query;
  $query = $this
    ->modifyQuery($query);
  if ($this->_db) {
    if (!@mysql_select_db($this->_db, $this->connection)) {
      return $this
        ->mysqlRaiseError(DB_ERROR_NODBSELECTED);
    }
  }
  if (!$this->autocommit && $ismanip) {
    if ($this->transaction_opcount == 0) {
      $result = @mysql_query('SET AUTOCOMMIT=0', $this->connection);
      $result = @mysql_query('BEGIN', $this->connection);
      if (!$result) {
        return $this
          ->mysqlRaiseError();
      }
    }
    $this->transaction_opcount++;
  }
  if (!$this->options['result_buffering']) {
    $result = @mysql_unbuffered_query($query, $this->connection);
  }
  else {
    $result = @mysql_query($query, $this->connection);
  }
  if (!$result) {
    return $this
      ->mysqlRaiseError();
  }
  if (is_resource($result)) {
    return $result;
  }
  return DB_OK;
}