Exemplo n.º 1
0
 /**
  * The error message string
  *
  * @access	private
  * @return	string
  */
 function _error_message()
 {
     return cubrid_error($this->conn_id);
 }
Exemplo n.º 2
0
 /**
  * Error
  *
  * Returns an array containing code and message of the last
  * database error that has occured.
  *
  * @return	array
  */
 public function error()
 {
     return array('code' => cubrid_errno($this->conn_id), 'message' => cubrid_error($this->conn_id));
 }
Exemplo n.º 3
0
 public function error()
 {
     if (!empty($this->connect)) {
         return cubrid_error($this->connect);
     } else {
         return false;
     }
 }
Exemplo n.º 4
0
 public static function error($err = null)
 {
     if ($err === null) {
         return cubrid_error();
     } else {
         return cubrid_error($err);
     }
 }
Exemplo n.º 5
0
 /**
  * Main function for querying to database
  *
  * @param $query The SQL querey statement
  * @return string|objet Return the resource id of query
  */
 public function query($sql)
 {
     if (is_null($this->link)) {
         $this->init();
     }
     $query = cubrid_query($sql, $this->link);
     $this->lastQuery = $sql;
     if ($this->lastError = cubrid_error($this->link)) {
         if ($this->throwError) {
             throw new \Exception($this->lastError);
         } else {
             $this->printError();
             return false;
         }
     }
     return $query;
 }
Exemplo n.º 6
0
 function query($query)
 {
     // This keeps the connection alive for very long running scripts
     if ($this->num_queries >= 500) {
         $this->disconnect();
         $this->connect($this->dbuser, $this->dbpassword, $this->dbname, $this->dbhost, $this->dbport);
     }
     // Initialise return
     $return_val = 0;
     // Flush cached values..
     $this->flush();
     // For reg expressions
     $query = trim($query);
     // Log how the function was called
     $this->func_call = "\$db->query(\"{$query}\")";
     // Keep track of the last query for debug..
     $this->last_query = $query;
     // Count how many queries there have been
     $this->num_queries++;
     // Start timer
     $this->timer_start($this->num_queries);
     // Use core file cache function
     if ($cache = $this->get_cache($query)) {
         // Keep tack of how long all queries have taken
         $this->timer_update_global($this->num_queries);
         // Trace all queries
         if ($this->use_trace_log) {
             $this->trace_log[] = $this->debug(false);
         }
         return $cache;
     }
     // If there is no existing database connection then try to connect
     if (!isset($this->dbh) || !$this->dbh) {
         $this->connect($this->dbuser, $this->dbpassword, $this->dbname, $this->dbhost, $this->dbport);
     }
     // Perform the query via std cubrid_query function..
     $this->result = @cubrid_query($query, $this->dbh);
     // If there is an error then take note of it..
     if ($str = @cubrid_error($this->dbh)) {
         $this->register_error($str);
         $this->show_errors ? trigger_error($str, E_USER_WARNING) : null;
         return false;
     }
     // Query was an insert, delete, update, replace
     if (preg_match("/^(insert|delete|update|replace|truncate|drop|create|alter)\\s+/i", $query)) {
         $is_insert = true;
         $this->rows_affected = @cubrid_affected_rows($this->dbh);
         // Take note of the insert_id
         if (preg_match("/^(insert|replace)\\s+/i", $query)) {
             $this->insert_id = @cubrid_insert_id($this->dbh);
         }
         // Return number fo rows affected
         $return_val = $this->rows_affected;
     } else {
         $is_insert = false;
         // Take note of column info
         $i = 0;
         while ($i < @cubrid_num_fields($this->result)) {
             $this->col_info[$i] = @cubrid_fetch_field($this->result);
             $i++;
         }
         // Store Query Results
         $num_rows = 0;
         while ($row = @cubrid_fetch_object($this->result)) {
             // Store relults as an objects within main array
             $this->last_result[$num_rows] = $row;
             $num_rows++;
         }
         @cubrid_free_result($this->result);
         // Log number of rows the query returned
         $this->num_rows = $num_rows;
         // Return number of rows selected
         $return_val = $this->num_rows;
     }
     // disk caching of queries
     $this->store_cache($query, $is_insert);
     // If debug ALL queries
     $this->trace || $this->debug_all ? $this->debug() : null;
     // Keep tack of how long all queries have taken
     $this->timer_update_global($this->num_queries);
     // Trace all queries
     if ($this->use_trace_log) {
         $this->trace_log[] = $this->debug(false);
     }
     return $return_val;
 }