function check_table_existence($conn_handle, $table_name) { $sql_stmt = "SELECT class_name FROM db_class WHERE class_name = ?"; $cubrid_req = cubrid_prepare($conn_handle, $sql_stmt); if (!$cubrid_req) { return -1; } $cubrid_retval = cubrid_bind($cubrid_req, 1, $table_name); if (!$cubrid_req) { cubrid_close_request($cubrid_req); return -1; } $cubrid_retval = cubrid_execute($cubrid_req); if (!$cubrid_retval) { cubrid_close_request($cubrid_req); return -1; } $row_num = cubrid_num_rows($cubrid_req); if ($row_num < 0) { cubrid_close_request($cubrid_req); return -1; } cubrid_close_request($cubrid_req); if ($row_num > 0) { return 1; } else { return 0; } }
function sql_num_rows($result) { $num = cubrid_num_rows($result); if ($num === false) { output_error("SQL Error: " . sql_error(), E_USER_ERROR); return false; } return $num; }
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; }
/** * Number of rows in the result set * * @access public * @return integer */ function num_rows() { return @cubrid_num_rows($this->result_id); }
public function numRows() { if (!empty($this->query)) { return cubrid_num_rows($this->query); } else { return 0; } }
function DROP_TABLE_IF_EXISTS($tablename, $link_identifier) { $id_result = cubrid_mysql_query_native("SELECT class_name FROM db_class WHERE class_name='" . $tablename . "'", $link_identifier); $rows = cubrid_num_rows($id_result); if ($rows > 1) { cubrid_execute($link_identifier, "DROP TABLE " . $tablename); } }
/** * Number of rows in the result set * * @return int */ public function num_rows() { return is_int($this->num_rows) ? $this->num_rows : ($this->num_rows = cubrid_num_rows($this->result_id)); }
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; }
/** * Check column exist status of the table * @param string $table_name table name * @param string $column_name column name * @return boolean */ function isColumnExists($table_name, $column_name) { $query = sprintf("select \"attr_name\" from \"db_attribute\" where " . "\"attr_name\" ='%s' and \"class_name\" = '%s%s'", $column_name, $this->prefix, $table_name); $result = $this->_query($query); if (cubrid_num_rows($result) > 0) { $output = TRUE; } else { $output = FALSE; } if ($result) { cubrid_close_request($result); } return $output; }
public function getRow($sql, $params = array()) { $result = $this->_execute($sql, $params); if (!$result) { return null; } if (cubrid_num_rows($result) < 1) { return null; } $arrDat = cubrid_fetch_assoc($result); /* // adodb.sf.net의 lib를 사용하면서 필드가 모두 소문자로 왔던 것 때문에 // 하위 호환성을 위한 코드 $tmpRow = array(); foreach ($arrDat as $k=>$v) $tmpRow[strtolower($k)] = $v; $arrDat = $tmpRow; unset($tmpRow); */ $this->_smartFreeResult($result); return $arrDat; }
/** * @group php-822 */ public function testCubridNumRows3() { if (OUTPUT_FUNCTION_NAME == true) { echo "\r\nRunning: " . __FUNCTION__ . " = "; } $this->sql = "create table test1 (id int, name varchar(30), age int)"; cubrid_execute($this->con, $this->sql); $this->sql = "insert into test1 values(1, 'test', 10)"; $this->req = cubrid_execute($this->con, $this->sql); $this->sql = "insert into test1 values(2, 'cj', 20)"; $this->req = cubrid_execute($this->con, $this->sql); $this->sql = "select * from test1"; $this->req = cubrid_execute($this->con, $this->sql, CUBRID_ASYNC); $cols_count = cubrid_num_rows($this->req); $this->assertEquals(0, $cols_count); }
/** * @brief 특정 테이블의 column의 정보를 return **/ function isColumnExists($table_name, $column_name) { $query = sprintf("select * from db_attribute where attr_name ='%s' and class_name = '%s%s'", $column_name, $this->prefix, $table_name); $result = $this->_query($query); if (cubrid_num_rows($result) > 0) { $output = true; } else { $output = false; } if ($result) { cubrid_close_request($result); } return $output; }