public function columnCount() { if ($this->_result) { return sybase_num_fields($this->_result); } return 0; }
/** * Constructor * * @param resource handle */ public function __construct($result, TimeZone $tz = NULL) { $fields = array(); if (is_resource($result)) { for ($i = 0, $num = sybase_num_fields($result); $i < $num; $i++) { $field = sybase_fetch_field($result, $i); $fields[$field->name] = $field->type; } } parent::__construct($result, $fields, $tz); }
/** * Number of fields in the result set * * @access public * @return integer */ function num_fields() { return @sybase_num_fields($this->result_id); }
/** * Returns information about a table or a result set * * NOTE: only supports 'table' and 'flags' if <var>$result</var> * is a table name. * * @param object|string $result DB_result object from a query or a * string containing the name of a table. * While this also accepts a query result * resource identifier, this behavior is * deprecated. * @param int $mode a valid tableInfo mode * * @return array an associative array with the information requested. * A DB_Error object on failure. * * @see DB_common::tableInfo() * @since Method available since Release 1.6.0 */ function tableInfo($result, $mode = null) { if (is_string($result)) { /* * Probably received a table name. * Create a result resource identifier. */ if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) { return $this->sybaseRaiseError(DB_ERROR_NODBSELECTED); } $id = @sybase_query("SELECT * FROM {$result} WHERE 1=0", $this->connection); $got_string = true; } elseif (isset($result->result)) { /* * Probably received a result object. * Extract the result resource identifier. */ $id = $result->result; $got_string = false; } else { /* * Probably received a result resource identifier. * Copy it. * Deprecated. Here for compatibility only. */ $id = $result; $got_string = false; } if (!is_resource($id)) { return $this->sybaseRaiseError(DB_ERROR_NEED_MORE_DATA); } if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) { $case_func = 'strtolower'; } else { $case_func = 'strval'; } $count = @sybase_num_fields($id); $res = array(); if ($mode) { $res['num_fields'] = $count; } for ($i = 0; $i < $count; $i++) { $f = @sybase_fetch_field($id, $i); // column_source is often blank $res[$i] = array('table' => $got_string ? $case_func($result) : $case_func($f->column_source), 'name' => $case_func($f->name), 'type' => $f->type, 'len' => $f->max_length, 'flags' => ''); if ($res[$i]['table']) { $res[$i]['flags'] = $this->_sybase_field_flags($res[$i]['table'], $res[$i]['name']); } if ($mode & DB_TABLEINFO_ORDER) { $res['order'][$res[$i]['name']] = $i; } if ($mode & DB_TABLEINFO_ORDERTABLE) { $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i; } } // free the result only if we were called on a table if ($got_string) { @sybase_free_result($id); } return $res; }
function _initrs() { global $ADODB_COUNTRECS; $this->_numOfRows = $ADODB_COUNTRECS ? @sybase_num_rows($this->_queryID) : -1; $this->_numOfFields = @sybase_num_fields($this->_queryID); }
/** * Enter description here... * * @param unknown_type $results */ function resultSet(&$results) { $this->results =& $results; $this->map = array(); $num_fields = sybase_num_fields($results); $index = 0; $j = 0; while ($j < $num_fields) { $column = sybase_fetch_field($results, $j); if (!empty($column->table)) { $this->map[$index++] = array($column->table, $column->name); } else { $this->map[$index++] = array(0, $column->name); } $j++; } }
function numCols($result) { $cols = @sybase_num_fields($result); if (!$cols) { return $this->raiseError(); } return $cols; }
/** * Return the number of fields of the current result * @return integer */ protected function num_fields() { return @sybase_num_fields($this->resResult); }
function query($query) { //if flag to convert query from MySql syntax to Sybase syntax is true //convert the query if ($this->convertMySqlTosybaseQuery == true) { $query = $this->ConvertMySqlTosybase($query); } // 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++; // Use core file cache function if ($cache = $this->get_cache($query)) { 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->dbhost); $this->select($this->dbname); } // Perform the query via std sybase_query function.. $this->result = @sybase_query($query); // If there is an error then take note of it.. if ($this->result == false) { $get_errorcodeSql = "SELECT @@ERROR as errorcode"; $error_res = @sybase_query($get_errorcodeSql, $this->dbh); $errorCode = @sybase_result($error_res, 0, "errorcode"); $get_errorMessageSql = "SELECT severity as errorSeverity, text as errorText FROM sys.messages WHERE message_id = " . $errorCode; $errormessage_res = @sybase_query($get_errorMessageSql, $this->dbh); if ($errormessage_res) { $errorMessage_Row = @sybase_fetch_row($errormessage_res); $errorSeverity = $errorMessage_Row[0]; $errorMessage = $errorMessage_Row[1]; } $sqlError = "ErrorCode: " . $errorCode . " ### Error Severity: " . $errorSeverity . " ### Error Message: " . $errorMessage . " ### Query: " . $query; $is_insert = true; $this->register_error($sqlError); $this->show_errors ? trigger_error($sqlError, E_USER_WARNING) : null; return false; } // Query was an insert, delete, update, replace $is_insert = false; if (preg_match("/^(insert|delete|update|replace)\\s+/i", $query)) { $this->rows_affected = @sybase_rows_affected($this->dbh); // Take note of the insert_id if (preg_match("/^(insert|replace)\\s+/i", $query)) { $identityresultset = @sybase_query("select SCOPE_IDENTITY()"); if ($identityresultset != false) { $identityrow = @sybase_fetch_row($identityresultset); $this->insert_id = $identityrow[0]; } } // Return number of rows affected $return_val = $this->rows_affected; } else { // Take note of column info $i = 0; while ($i < @sybase_num_fields($this->result)) { $this->col_info[$i] = @sybase_fetch_field($this->result); $i++; } // Store Query Results $num_rows = 0; while ($row = @sybase_fetch_object($this->result)) { // Store relults as an objects within main array $this->last_result[$num_rows] = $row; $num_rows++; } @sybase_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; return $return_val; }
function num_fields() { return sybase_num_fields($this->Query_ID); }
function NumFields() { if ($this->res) { return sybase_num_fields($this->res); } else { return -1; } }
public function numFields() { if (!empty($this->query)) { return sybase_num_fields($this->query); } else { return 0; } }
private function _getTextFields($result) { if ($this->_result == $result) { return $this->_text_fields; } $this->_result = $result; $this->_text_fields = array(); for ($i = sybase_num_fields($result) - 1; $i >= 0; $i--) { $type = sybase_fetch_field($result, $i); if (!$type->numeric) { $this->_text_fields[$type->name] = $type->type; } } return $this->_text_fields; }