php sybase_fetch_array使用方法
返回數(shù)組資料。
語法: array sybase_fetch_array(int result);
返回值: 數(shù)組
函數(shù)種類: 數(shù)據(jù)庫功能
內(nèi)容說明
本函數(shù)用來將查詢結(jié)果 result 拆到數(shù)組變量中。若 result 沒有資料,則返回 false 值。而本函數(shù)可以說是 sybase_fetch_row() 的加強(qiáng)函數(shù),除可以將返回列及數(shù)字索引放入數(shù)組之外,還可以將文字索引放入數(shù)組中。
使用范例
這是 joey@samaritan.com (22-Feb-1999) 所提出的例子
實(shí)例1:
<?php
$q = sybase_query("SELECT COUNT(DISTINCT OPPORTUNITY_ID) FROM M_OPP_INTERESTS WHERE INTEREST_ID = $i_id", $db);
while ($op_by_int = sybase_fetch_array($q)) {
while (list($k, $v) = each($op_by_int)) {
echo "\$op[$k] => $v\n";
}
?>
返回資料如下
$op[0] => 2164
$op[computed] => 2164
實(shí)例2:
<?php
$dbh = sybase_connect('SYBASE', '', '');
$q = sybase_query('SELECT * FROM p, a WHERE p.person_id= a.person_id');
var_dump(sybase_fetch_array($q));
sybase_close($dbh);
?>
The above example would produce the following output (assuming the two tables only have each one column called "person_id"):
array(4) {
[0]=>
int(1)
["person_id"]=>
int(1)
[1]=>
int(1)
["person_id1"]=>
int(1)
}
相關(guān)文章
PHP4實(shí)際應(yīng)用經(jīng)驗篇(4)
PHP4實(shí)際應(yīng)用經(jīng)驗篇(4)...2006-10-10淺析php中json_encode()和json_decode()
從5.2版本開始,PHP原生提供json_encode()和json_decode()函數(shù),前者用于編碼,后者用于解碼。下面我們來分析下這2個函數(shù)2014-05-05