91亚洲精品福利在线播放,欧美日韩国产在线人成app,天天躁日日躁疯人影院,sao虎视频最新网站入口,精品久久久久久中文字幕女

PDOStatement::columnCount

(PHP 5 >= 5.1.0, PHP 7, PHP 8, PECL pdo >= 0.2.0)

PDOStatement::columnCount 返回結果集中的列數

說(shuō)明

PDOStatement::columnCount(): int

使用 PDOStatement::columnCount() 返回由 PDOStatement 對象代表的結果集中的列數。

如果是由 PDO::query() 返回的 PDOStatement 對象,則列數計算立即可用。

如果是由 PDO::prepare() 返回的 PDOStatement 對象,則在調用 PDOStatement::execute() 之前都不能準確地計算出列數。

返回值

返回由 PDOStatement 對象代表的結果集中的列數。如果沒(méi)有結果集,則 PDOStatement::columnCount() 返回 0。

范例

示例 #1 計算列數

下面例子演示如何使用 PDOStatement::columnCount() 操作一個(gè)結果集和一個(gè)空集。

<?php
$dbh 
= new PDO('odbc:sample''db2inst1''ibmdb2');

$sth $dbh->prepare("SELECT name, colour FROM fruit");

/*  計算一個(gè)(不存在)的結果集中的列數 */
$colcount $sth->columnCount();
print(
"Before execute(), result set has $colcount columns (should be 0)\n");

$sth->execute();

/* 計算結果集中的列數 */
$colcount $sth->columnCount();
print(
"After execute(), result set has $colcount columns (should be 2)\n");

?>

以上例程會(huì )輸出:

Before execute(), result set has 0 columns (should be 0)
After execute(), result set has 2 columns (should be 2)

參見(jiàn)

91亚洲精品福利在线播放,欧美日韩国产在线人成app,天天躁日日躁疯人影院,sao虎视频最新网站入口,精品久久久久久中文字幕女