/**
  * Does a query with placeholders
  */
 function db_query($q)
 {
     $this->db_connect();
     $this->statement_handle = null;
     $this->sql = $this->db_merge($q);
     // Do the query
     $start = microtime(true);
     pg_send_query($this->db, $this->sql);
     $this->statement_handle = pg_get_result($this->db);
     $this->duration = microtime(true) - $start;
     ar_logger('SQL: [' . number_format($this->duration, 6) . '] ' . $this->sql, $this->db_connection);
     $GLOBALS['db_time'] += $this->duration;
     if ($error = pg_result_error($this->statement_handle)) {
         $errorstr = 'SQL ERROR: ' . $error . "\nSTATEMENT: " . $this->sql;
         //debug($errorstr);
         ar_logger($errorstr, $this->db_connection);
         throw_error($errorstr);
     }
     $this->sql = array();
 }
Beispiel #2
0
 /**
  * Does a query with placeholders
  */
 function db_query($q)
 {
     $this->db_connect();
     $this->statement_handle = null;
     $this->sql = $this->db_merge($q);
     $this->last_sql = $this->sql;
     $start = microtime(true);
     $this->statement_handle = mysql_query($this->sql, $this->db);
     $this->duration = microtime(true) - $start;
     ar_logger('SQL: [' . number_format($this->duration, 6) . '] ' . $this->sql, $this->db_connection);
     $GLOBALS['db_time'] += $this->duration;
     if ($this->statement_handle === false) {
         $errorstr = 'SQL ERROR: ' . mysql_error($this->db) . "\nSTATEMENT: " . $this->sql;
         //debug($errorstr);
         ar_logger($errorstr, $this->db_connection);
         throw_error($errorstr);
     }
     $this->sql = array();
 }