本文整理汇总了PHP中sybase_fetch_row函数的典型用法代码示例。如果您正苦于以下问题:PHP sybase_fetch_row函数的具体用法?PHP sybase_fetch_row怎么用?PHP sybase_fetch_row使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sybase_fetch_row函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lastInsertId
public function lastInsertId($name = '')
{
if ($result = sybase_query('SELECT @@IDENTITY', $this->link)) {
$row = sybase_fetch_row($result);
if ($row[0] === null) {
return -1;
}
return $row[0];
}
return false;
}
示例2: asArray
public function asArray()
{
$json = [];
$i = 0;
while ($row = sybase_fetch_row($this->result)) {
foreach ($row as $_v) {
$json[$i][] = iconv("cp936", "utf-8", $_v);
}
$i++;
}
return $json;
}
示例3: fetchInto
/**
* Fetch a row and insert the data into an existing array.
*
* Formating of the array and the data therein are configurable.
* See DB_result::fetchInto() for more information.
*
* @param resource $result query result identifier
* @param array $arr (reference) array where data from the row
* should be placed
* @param int $fetchmode how the resulting array should be indexed
* @param int $rownum the row number to fetch
*
* @return mixed DB_OK on success, null when end of result set is
* reached or on failure
*
* @see DB_result::fetchInto()
* @access private
*/
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
{
if ($rownum !== null) {
if (!@sybase_data_seek($result, $rownum)) {
return null;
}
}
if ($fetchmode & DB_FETCHMODE_ASSOC) {
if (function_exists('sybase_fetch_assoc')) {
$arr = @sybase_fetch_assoc($result);
} else {
if ($arr = @sybase_fetch_array($result)) {
foreach ($arr as $key => $value) {
if (is_int($key)) {
unset($arr[$key]);
}
}
}
}
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
$arr = array_change_key_case($arr, CASE_LOWER);
}
} else {
$arr = @sybase_fetch_row($result);
}
if (!$arr) {
// reported not work as seems that sybase_get_last_message()
// always return a message here
//if ($errmsg = @sybase_get_last_message()) {
// return $this->sybaseRaiseError($errmsg);
//} else {
return null;
//}
}
if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
$this->_rtrimArrayValues($arr);
}
if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
$this->_convertNullArrayValuesToEmpty($arr);
}
return DB_OK;
}
示例4: _fetch_row
protected function _fetch_row()
{
return sybase_fetch_row($this->_result);
}
示例5: sql_fetch_row
function sql_fetch_row(&$res, $nr = 0)
{
global $dbtype;
switch ($dbtype) {
case "MySQL":
$row = mysql_fetch_row($res);
return $row;
break;
case "mSQL":
$row = msql_fetch_row($res);
return $row;
break;
case "postgres":
case "postgres_local":
if ($res->get_total_rows() > $res->get_fetched_rows()) {
$row = pg_fetch_row($res->get_result(), $res->get_fetched_rows());
$res->increment_fetched_rows();
return $row;
} else {
return false;
}
break;
case "ODBC":
case "ODBC_Adabas":
$row = array();
$cols = odbc_fetch_into($res, $nr, $row);
return $row;
break;
case "Interbase":
$row = ibase_fetch_row($res);
return $row;
break;
case "Sybase":
$row = sybase_fetch_row($res);
return $row;
break;
default:
break;
}
}
示例6: fetchInto
function fetchInto($result, &$ar, $fetchmode, $rownum = null)
{
if ($rownum !== null) {
if (!sybase_data_seek($result, $rownum)) {
return $this->raiseError();
}
}
$ar = $fetchmode & DB_FETCHMODE_ASSOC ? @sybase_fetch_array($result) : @sybase_fetch_row($result);
if (!$ar) {
// reported not work as seems that sybase_get_last_message()
// always return a message here
//if ($errmsg = sybase_get_last_message()) {
// return $this->raiseError($errmsg);
//} else {
return null;
//}
}
return DB_OK;
}
示例7: insert_id
/**
* Returns the ID of the latest insert
*
* @return integer
* @access public
* @author Adam Greene <phpmyfaq@skippy.fastmail.fm>
* @since 2004-12-10
*/
function insert_id($table, $field)
{
$sql = "SELECT max({$field}) FROM {$table} ";
$rs = sybase_query($sql, $this->conn);
$row = sybase_fetch_row($rs);
if (isset($row[0]) && $row[0] > 0) {
return $row[0] + 1;
}
return 1;
}
示例8: _fetch
function _fetch($ignore_fields = false)
{
if ($this->fetchMode == ADODB_FETCH_NUM) {
$this->fields = @sybase_fetch_row($this->_queryID);
} else {
if ($this->fetchMode == ADODB_FETCH_ASSOC) {
$this->fields = @sybase_fetch_row($this->_queryID);
$this->fields = $this->GetRowAssoc(ADODB_CASE_ASSOC);
} else {
$this->fields = @sybase_fetch_array($this->_queryID);
}
}
return is_array($this->fields);
}
示例9: query
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;
}
示例10: fetch_row
/**
* Fetch the current row as enumerated array
* @return array
*/
protected function fetch_row()
{
return @sybase_fetch_row($this->resResult);
}
示例11: errorNative
/**
* Gets the DBMS' native error code produced by the last query
*
* @return int the DBMS' error code
*/
function errorNative()
{
$res = @mssql_query('select @@ERROR as ErrorCode', $this->connection);
if (!$res) {
return DB_ERROR;
}
$row = @sybase_fetch_row($res);
return $row[0];
}
示例12: getMyFines
/**
* Get Patron Fines
*
* This is responsible for retrieving all fines by a specific patron.
*
* @param array $patron The patron array from patronLogin
*
* @throws \VuFind\Exception\Date
* @throws ILSException
* @return mixed Array of the patron's fines on success.
*/
public function getMyFines($patron)
{
$aid = $patron['address_id_nr'];
$iln = $patron['iln'];
//$lang = $patron['lang'];
$sql = "select o.ppn" . ", r.costs_code" . ", r.costs" . ", rtrim(convert(char(20),r.date_of_issue,104))" . ", rtrim(convert(char(20),r.date_of_creation,104))" . ", 'Overdue' as fines" . ", o.shorttitle" . " from requisition r, ous_copy_cache o, volume v" . " where r.address_id_nr=" . $aid . "" . " and r.iln=" . $iln . " and r.id_number=v.volume_number" . " and v.epn=o.epn" . " and r.iln=o.iln" . " and r.costs_code in (1, 2, 3, 4, 8)" . " union select id_number" . ", r.costs_code" . ", r.costs" . ", rtrim(convert(char(20),r.date_of_issue,104))" . ", rtrim(convert(char(20),r.date_of_creation,104))" . ", r.extra_information" . ", '' as zero" . " from requisition r" . " where r.address_id_nr=" . $aid . "" . " and r.costs_code not in (1, 2, 3, 4, 8)" . "";
try {
$result = [];
$sqlStmt = sybase_query($sql);
while ($row = sybase_fetch_row($sqlStmt)) {
//$fine = $this->translate(('3'==$row[1])?'Overdue':'Dues');
$fine = $this->picaRecode($row[5]);
$amount = null == $row[2] ? 0 : $row[2] * 100;
//$balance = (null==$row[3])?0:$row[3]*100;
$checkout = substr($row[3], 0, 12);
$duedate = substr($row[4], 0, 12);
$title = $this->picaRecode(substr($row[6], 0, 12));
$result[] = ['id' => $this->prfz($row[0]), 'amount' => $amount, 'balance' => $amount, 'checkout' => $checkout, 'duedate' => $duedate, 'fine' => $fine, 'title' => $title];
}
return $result;
} catch (\Exception $e) {
throw new ILSException($e->getMessage());
}
return [];
}
示例13: FetchAllRows
function FetchAllRows()
{
$retVal = array();
$i = 0;
// bump up if just ran query
if ($this->cur == -1) {
$this->cur = 0;
}
while ($a = @sybase_fetch_row($this->res)) {
$this->cur++;
$retVal[$i++] = $a;
}
return $retVal;
}
示例14: fetchResult
/**
* Fetches the next row from the current result set
*
* @return unknown
*/
function fetchResult()
{
if ($row = sybase_fetch_row($this->results)) {
$resultRow = array();
$i = 0;
foreach ($row as $index => $field) {
list($table, $column) = $this->map[$index];
$resultRow[$table][$column] = $row[$index];
$i++;
}
return $resultRow;
} else {
return false;
}
}
示例15: query0
/**
* Execute any statement
*
* @param string sql
* @param bool buffered default TRUE
* @return rdbms.sybase.SybaseResultSet or TRUE if no resultset was created
* @throws rdbms.SQLException
*/
protected function query0($sql, $buffered = TRUE)
{
if (!is_resource($this->handle)) {
if (!($this->flags & DB_AUTOCONNECT)) {
throw new SQLStateException('Not connected');
}
$c = $this->connect();
// Check for subsequent connection errors
if (FALSE === $c) {
throw new SQLStateException('Previously failed to connect');
}
}
if (!$buffered) {
$result = @sybase_unbuffered_query($sql, $this->handle, FALSE);
} else {
if ($this->flags & DB_UNBUFFERED) {
$result = @sybase_unbuffered_query($sql, $this->handle, $this->flags & DB_STORE_RESULT);
} else {
$result = @sybase_query($sql, $this->handle);
}
}
if (FALSE === $result) {
$message = 'Statement failed: ' . trim(sybase_get_last_message()) . ' @ ' . $this->dsn->getHost();
if (!is_resource($error = sybase_query('select @@error', $this->handle))) {
// The only case selecting @@error should fail is if we receive a
// disconnect. We could also check on the warnings stack if we can
// find the following:
//
// Sybase: Client message: Read from SQL server failed. (severity 78)
//
// but that seems a bit errorprone.
throw new SQLConnectionClosedException($message, $sql);
}
$code = current(sybase_fetch_row($error));
switch ($code) {
case 1205:
// Deadlock
throw new SQLDeadlockException($message, $sql, $code);
default:
// Other error
throw new SQLStatementFailedException($message, $sql, $code);
}
}
return TRUE === $result ? $result : new SybaseResultSet($result, $this->tz);
}