PDOStatement::columnCount
傳回結果集內的資料行數目。
語法
int PDOStatement::columnCount ();
傳回值
傳回結果集內的資料行數目。 如果結果集是空的,則傳回零。
備註
Microsoft Drivers for PHP for SQL Server 2.0 版已新增 PDO 支援。
範例
<?php
$database = "AdventureWorks";
$server = "(local)";
$conn = new PDO( "sqlsrv:server=$server ; Database = $database", "", "");
$query = "select * from Person.ContactType";
$stmt = $conn->prepare( $query );
print $stmt->columnCount(); // 0
echo "\n";
$stmt->execute();
print $stmt->columnCount();
echo "\n";
$stmt = $conn->query("select * from HumanResources.Department");
print $stmt->columnCount();
?>