function __tcSqlLogEnd($result, $cachedResult = 0) { global $__tcSqlLog, $__tcSqlQueryBeginTime, $__tcSqlLogCount, $__tcPageStartTime; static $client_encoding = ''; $tcSqlQueryEndTime = explode(' ', microtime()); $elapsed = $tcSqlQueryEndTime[1] - $__tcSqlQueryBeginTime[1] + ($tcSqlQueryEndTime[0] - $__tcSqlQueryBeginTime[0]); // if( !$client_encoding ) { // $client_encoding = str_replace('_','-',cubrid_client_encoding()); // } $client_encoding = 'utf-8'; // if( $client_encoding != 'utf8' && function_exists('iconv') ) { // $__tcSqlLog[$__tcSqlLogCount]['error'] = iconv( $client_encoding, 'utf-8', mysql_error()); // } // else { $__tcSqlLog[$__tcSqlLogCount]['error'] = iconv('euc-kr', 'utf-8', cubrid_error_msg()); // } $__tcSqlLog[$__tcSqlLogCount]['errno'] = cubrid_error_code(); if ($cachedResult == 0) { $__tcSqlLog[$__tcSqlLogCount]['elapsed'] = ceil($elapsed * 10000) / 10; } else { $__tcSqlLog[$__tcSqlLogCount]['elapsed'] = 0; } $__tcSqlLog[$__tcSqlLogCount]['elapsed'] = sprintf("%4.1f", $__tcSqlLog[$__tcSqlLogCount]['elapsed']); $__tcSqlLog[$__tcSqlLogCount]['cached'] = $cachedResult; $__tcSqlLog[$__tcSqlLogCount]['rows'] = 0; $__tcSqlLog[$__tcSqlLogCount]['endtime'] = $tcSqlQueryEndTime[1] - $__tcPageStartTime[1] + ($tcSqlQueryEndTime[0] - $__tcPageStartTime[0]); $__tcSqlLog[$__tcSqlLogCount]['endtime'] = sprintf("%4.1f", ceil($__tcSqlLog[$__tcSqlLogCount]['endtime'] * 10000) / 10); if (!$cachedResult && cubrid_error_code() == 0) { switch (strtolower(substr($__tcSqlLog[$__tcSqlLogCount]['sql'], 0, 6))) { case 'select': $__tcSqlLog[$__tcSqlLogCount]['rows'] = cubrid_num_rows($result); break; case 'insert': case 'delete': case 'update': $__tcSqlLog[$__tcSqlLogCount]['rows'] = cubrid_affected_rows($result); break; } } $__tcSqlLogCount++; $__tcSqlQueryBeginTime = 0; }
/** * Affected Rows * * @access public * @return integer */ function affected_rows() { return @cubrid_affected_rows($this->conn_id); }
/** * Affected Rows * * @return int */ public function affected_rows() { return @cubrid_affected_rows(); }
public function affectedRows() { if (!empty($this->connect)) { return cubrid_affected_rows($this->connect); } else { return false; } }
public static function num_rows($handle = null) { switch (self::$lastQueryType) { case 'select': return cubrid_num_rows($handle); break; default: return cubrid_affected_rows($handle); break; } return null; }
public function getAffectedRows() { return cubrid_affected_rows($this->_conn); }
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; }
public function testCubridErrorCode2() { if (OUTPUT_FUNCTION_NAME == true) { echo "\r\nRunning: " . __FUNCTION__ . " = "; } try { $res = cubrid_affected_rows(); } catch (Exception $e) { //echo $e->getMessage(); $this->assertEquals(0, cubrid_error_code()); $this->assertEquals(0, cubrid_error_code_facility()); $this->assertEquals('', cubrid_error_msg()); } }