Export (0) Print
Expand All

PDOStatement::columnCount

Returns the number of columns in a result set.


int PDOStatement::columnCount ();

Returns the number of columns in a result set. Returns zero if the result set is empty.

Support for PDO was added in version 2.0 of the Microsoft Drivers for PHP for SQL Server.

<?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();
?>

Reference

Other Resources

PDO

Community Additions

Show:
© 2014 Microsoft