public function closeCursor() { if ($this->_result) { sybase_free_result($this->_result); $this->_result = false; } }
/** * Close resultset and free result memory * * @return bool success */ public function close() { if (!$this->handle) { return; } $r = sybase_free_result($this->handle); $this->handle = NULL; return $r; }
public function exec(&$statement) { if ($result = @sybase_query($statement, $this->link)) { if (is_resource($result)) { sybase_free_result($result); return 0; } return sybase_affected_rows($this->link); } return false; }
function next_record() { $this->Record = sybase_fetch_array($this->Query_ID); $this->Row += 1; $stat = is_array($this->Record); if (!$stat && $this->Auto_Free) { sybase_free_result($this->Query_ID); $this->Query_ID = 0; } return $stat; }
public function findBookByPage($qtxt, $offset, $itemCountPerPage) { $link = $this->getDB(); $qtxt = iconv("utf-8", "gbk//ignore", $qtxt); $rs = sybase_query("exec llt_searchByPage " . "'" . $qtxt . "'," . $offset . "," . $itemCountPerPage, $link); $data = array(); while ($row = sybase_fetch_array($rs)) { $book = new Book(); $book->no = $row["ctrlno"]; $book->title = iconv("gbk", "utf-8//ignore", $row["title"]); $book->authors = iconv("gbk", "utf-8//ignore", $row["authors"]); $book->publisher = iconv("gbk", "utf-8//ignore", $row["publisher"]); $book->pubdate = iconv("gbk", "utf-8//ignore", $row["pubdate"]); $book->barcode = $row["barcode"]; $book->status = iconv("gbk", "utf-8//ignore", $row["status"]); $book->classno = iconv("gbk", "utf-8//ignore", $row["classno"]); array_push($data, $book); } sybase_free_result($rs); sybase_close($link); return $data; }
/** * Free the result * * @return null */ function free_result() { if (is_resource($this->result_id)) { sybase_free_result($this->result_id); $this->result_id = FALSE; } }
/** * 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; }
public function close() { sybase_free_result($this->result); sybase_close($this->link); }
function _close() { return @sybase_free_result($this->_queryID); }
/** * Get the flags for a field * * Currently supports: * + <samp>unique_key</samp> (unique index, unique check or primary_key) * + <samp>multiple_key</samp> (multi-key index) * * @param string $table the table name * @param string $column the field name * * @return string space delimited string of flags. Empty string if none. * * @access private */ function _sybase_field_flags($table, $column) { static $tableName = null; static $flags = array(); if ($table != $tableName) { $flags = array(); $tableName = $table; /* We're running sp_helpindex directly because it doesn't exist in * older versions of ASE -- unfortunately, we can't just use * DB::isError() because the user may be using callback error * handling. */ $res = @sybase_query("sp_helpindex {$table}", $this->connection); if ($res === false || $res === true) { // Fake a valid response for BC reasons. return ''; } while (($val = sybase_fetch_assoc($res)) !== false) { if (!isset($val['index_keys'])) { /* No useful information returned. Break and be done with * it, which preserves the pre-1.7.9 behaviour. */ break; } $keys = explode(', ', trim($val['index_keys'])); if (sizeof($keys) > 1) { foreach ($keys as $key) { $this->_add_flag($flags[$key], 'multiple_key'); } } if (strpos($val['index_description'], 'unique')) { foreach ($keys as $key) { $this->_add_flag($flags[$key], 'unique_key'); } } } sybase_free_result($res); } if (array_key_exists($column, $flags)) { return implode(' ', $flags[$column]); } return ''; }
function sql_free_result($res) { global $dbtype; switch ($dbtype) { case "MySQL": $row = mysql_free_result($res); return $row; break; case "mSQL": $row = msql_free_result($res); return $row; break; case "postgres": case "postgres_local": $rows = pg_FreeResult($res->get_result()); return $rows; break; case "ODBC": case "ODBC_Adabas": $rows = odbc_free_result($res); return $rows; break; case "Interbase": echo "<BR>Error! PHP dosen't support ibase_numrows!<BR>"; return $rows; break; case "Sybase": $rows = sybase_free_result($res); return $rows; break; } }
function freeResult($result) { if (is_resource($result)) { return @sybase_free_result($result); } if (!isset($this->prepare_tokens[(int) $result])) { return false; } unset($this->prepare_tokens[(int) $result]); unset($this->prepare_types[(int) $result]); return true; }
<?php //phpinfo(); $link = @sybase_connect('lltang2000', 'sa', '******') or die("Could not connect !"); //连接数据库,第一空必须写服务名称,不能是ip; echo "Connected successfully<br>"; $db = @sybase_select_db("sulcmis", $link) or die("数据库没有选择"); echo "数据库选择成功<br>"; $sql = "select ctrlNo,F200,F210c from b_brief where ctrlNo<100"; $rs = sybase_query($sql, $link); //查询表 if (!$rs) { echo "SQL:" . $sql . "执行失败!"; exit; } //$sybase = sybase_fetch_array($rs); //print_r($sybase);//结束 echo '<table border="1"><tr><td>CtrlNO</td><td>F200</td><td>F210c</td>'; while ($row = sybase_fetch_array($rs)) { $id = $row["ctrlNo"]; $F200 = $row["F200"]; $F210c = $row["F210c"]; echo '<tr><td>' . $id . '</td><td>' . $F200 . '</td><td>' . $F210c . '</td></tr>'; } echo '</table>'; sybase_free_result($rs); sybase_close($link); ?>
/** * Free the current result */ public function free() { if (is_resource($this->resResult)) { @sybase_free_result($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 GetLastInsertID($sTable) { $res = sybase_query('SELECT @@identity', $this->conn); if ($res) { $Record = @sybase_fetch_array($res); sybase_free_result($res); return $Record[0]; } trigger_error('Could not retrieve @@identity of newly inserted record!!'); return -1; }