Skip to content

Latest commit

 

History

History
58 lines (44 loc) · 1.38 KB

File metadata and controls

58 lines (44 loc) · 1.38 KB
title PDOStatement::columnCount | Microsoft Docs
ms.custom
ms.date 01/19/2017
ms.prod sql
ms.prod_service connectivity
ms.reviewer
ms.technology connectivity
ms.topic conceptual
ms.assetid 8d89a568-0c7c-40dd-9f54-db7313600df3
author David-Engel
ms.author v-daenge

PDOStatement::columnCount

[!INCLUDEDriver_PHP_Download]

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 [!INCLUDEssDriverPHP].

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

See Also

PDOStatement Class

PDO