







![]() ![]() |
Microsoft Drivers for PHP for SQL Server version 2.0 and 3.0 |
PDOStatement::columnCount |
Example See Also Send Feedback |
Returns the number of columns in a result set.
Syntax
int PDOStatement::columnCount (); |
Return Value
Returns the number of columns in a result set. Returns zero if the result set is empty.
Remarks
Support for PDO was added in version 2.0 of the Microsoft Drivers for PHP for SQL Server.
Example
![]() |
|
---|---|
<?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(); ?> |