PDOStatement :: columnCount 이후
PDOStatement :: columnCount 이후는 - 결과 집합의 열 수를 돌려줍니다. (PHP 5> = 5.1.0, PECL의 PDO> = 0.2.0)
설명
문법
int PDOStatement::columnCount ( void )
사용 PDOStatement :: columnCount 이후는 () 세트를 나타내는 PDOStatement 객체에 의해 결과에서 열 수를 돌려줍니다.
PDOStatement 객체가 PDO :: 쿼리 ()에 의해 반환되는 경우, 즉시 사용 가능한 열 수를 계산합니다.
PDO :: 준비가 () PDOStatement를 호출하는 PDOStatement 객체를 반환하는 경우 :: 정확하게 열 (전)의 수를 계산할 수 없습니다 실행합니다.
반환 값
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)