小白教程
所有教程
关于
Search
172.70.100.206
172.70.100.206
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Pdostatement columncount”的源代码
本页内容
上一节:
Pdostatement_closecursor
下一节:
Pdostatement_debugdumpparams
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:PDOStatement::columnCount}}[[Category:PHP PDO 参考手册|26]] = PDOStatement::columnCount = [[:Category:PHP PDO 参考手册]] PDOStatement::columnCount — 返回结果集中的列数。(PHP 5 >= 5.1.0, PECL pdo >= 0.2.0) == 说明 == === 语法 === <pre> int PDOStatement::columnCount ( void ) </pre> 使用 PDOStatement::columnCount() 返回由 PDOStatement 对象代表的结果集中的列数。 如果是由 PDO::query() 返回的 PDOStatement 对象,则列数计算立即可用。 如果是由 PDO::prepare() 返回的 PDOStatement 对象,则在调用 PDOStatement::execute() 之前都不能准确地计算出列数。 == 返回值 == 返回由 PDOStatement 对象代表的结果集中的列数。如果没有结果集,则 PDOStatement::columnCount() 返回 0。 === 计算列数 === 下面例子演示如何使用 PDOStatement::columnCount() 操作一个结果集和一个空集。 <pre> <?php $dbh = new PDO('odbc:sample', 'db2inst1', 'ibmdb2'); $sth = $dbh->prepare("SELECT name, colour FROM fruit"); /* 计算一个(不存在)的结果集中的列数 */ $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"); ?> </pre> 以上例程会输出: <pre> Before execute(), result set has 0 columns (should be 0) After execute(), result set has 2 columns (should be 2) </pre> [[:Category:PHP PDO 参考手册]]
返回至“
Pdostatement columncount
”。
上一节:
Pdostatement_closecursor
下一节:
Pdostatement_debugdumpparams