PDOStatement::columnCount
PDOStatement::columnCount — 返回结果集中的列数。(PHP 5 >= 5.1.0, PECL pdo >= 0.2.0)
说明
语法
int PDOStatement::columnCount ( void )高佣联盟 www.cgewang.com
使用 PDOStatement::columnCount() 返回由 PDOStatement 对象代表的结果集中的列数。
如果是由 PDO::query() 返回的 PDOStatement 对象,则列数计算立即可用。
如果是由 PDO::prepare() 返回的 PDOStatement 对象,则在调用 PDOStatement::execute() 之前都不能准确地计算出列数。
返回值
返回由 PDOStatement 对象代表的结果集中的列数。如果没有结果集,则 PDOStatement::columnCount() 返回 0。
实例
计算列数
下面例子演示如何使用 PDOStatement::columnCount() 操作一个结果集和一个空集。
<?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"); ?>
以上例程会输出:
Before execute(), result set has 0 columns (should be 0)
After execute(), result set has 2 columns (should be 2)
PDOStatement::columnCount的更多相关文章
- PDO和PDOStatement类常用方法
PDO — PDO 类 PDO::beginTransaction — 启动一个事务 PDO::commit — 提交一个事务 PDO::__construct — 创建一个表示数据库连接的 PDO ...
- PDO、PDOStatement、PDOException
最近在学PDO 比较详细的资料 出处:http://blog.csdn.net/hsst027/article/details/23682003 PDO中包含三个预定义的类,它们分别是PDO.PDO ...
- PHP面向对象07_PDO
oop007复习 2014-9-4 9:42:28 摘要: 1.pdo的作用 2.pdo的安装 3.pdo连接属性设置 4.pdo对象和PDOStatement对象 5.pdo预处理 6.pdo事务机 ...
- PHP MSSQL数据操作PDO API
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...
- php mysql PDO使用
<?php $dbh = new PDO('mysql:host=localhost;dbname=access_control', 'root', ''); $dbh->setAttri ...
- php之PDO使用【转载】
<?php $dbh = new PDO('mysql:host=localhost;dbname=access_control', 'root', ''); $dbh->setAttri ...
- php PDO mysql
php PDO写法连接mysql: $db=new PDO("mysql:host=localhost;dbname=sql","root","roo ...
- pdo连接mysql操作方法
PDO常用方法: PDO::query()主要用于有记录结果返回的操作(PDOStatement),特别是select操作. PDO::exec()主要是针对没有结果集合返回的操作.如insert,u ...
- 用trie树实现输入提示功能,输入php函数名,提示php函数
参照刘汝佳的trie树 结构体 #include "stdio.h" #include "stdlib.h" #include "string.h&q ...
随机推荐
- sass安装与教程
首先下载ruby http://dlsw.baidu.com/sw-search-sp/soft/ff/22711/rubyinstaller_V2.2.2.95_setup.1439890355.e ...
- 文件读取一些payload
Windows: C:boot.ini //查看系统版本 C:WindowsSystem32inetsrvMetaBase.xml //IIS配置文件 C:Windowsrepairsam //存储系 ...
- rabbitmq部署及配置与验证
1. 场景描述 朋友项目需要弄个测试环境,稍微帮忙了下,系统不复杂,但是需要自己安装mysql.Reids.Es.RabbitMq等,Mq主要用在同步用户信息与发送站内消息和短信上,RabbitMq以 ...
- JS基础知识点(一)
原始类型 null undefined boolean number string symbol 注意 原始类型存储的都是值,是没有函数可以调用的,但实际上除null和undefined外,其他类型使 ...
- python3 读取chrome浏览器cookies
原文链接:https://www.cnblogs.com/gayhub/p/pythongetcookiefromchrome.html 好几年前我在做一些自动化的脚本时,脑子里也闪过这样的想法:能不 ...
- redis的集群化方案
关于 目前有三种 (1)Twitter开发的twemproxy (2)豌豆荚开发的codis (3)redis官方的redis-cluster Twemproxy 架构简单 就是用proxy对后端re ...
- (5)webpack中url-loader的使用
为什么要使用url-loader 在前面已经介绍了css文件可以使用第三方loader去加载. 在一个项目中,也不仅仅只有html,js和css文件,还有图片文件,字体文件等等.当我们给一个css样式 ...
- 生产日志文件太大NotePad++无法打开
问题1:NotePad++无法打开 解决方式:下载软件 LogView Pro ,用 LogView Pro打开 https://download.csdn.net/download/u0145212 ...
- OSCP Learning Notes - Buffer Overflows(3)
Finding Bad Characters 1. Find the bad charaters in the following website: https://bulbsecurity.com/ ...
- Python Ethical Hacking - WEB PENETRATION TESTING(5)
Guessing Login Information on Login Pages Our target website: http://10.0.0.45/dvwa/login.php #!/usr ...