public
Created

Zend\Db\Adapter\Driver\Pdo\Result not returning row count?

  • Download Gist
sqlite_count.output
1 2 3
$ php sqlite_count.php
Row Count: 0
Row 0: request_key=DCE2D890895CF02, email_address=foo@bar.com, request_time=2001-01-01 01:01:01,
sqlite_count.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
<?php
 
use Zend\Loader\StandardAutoloader as Autoloader,
Zend\Db\Adapter\Adapter as DbAdapter;
 
require_once 'Zend/Loader/StandardAutoloader.php';
$autoloader = new Autoloader();
$autoloader->register();
 
@unlink('test.db');
$adapter = new DbAdapter(array(
'driver' => 'Pdo',
'dsn' => 'sqlite:test.db'
));
 
$tableSchema = <<<EOB
CREATE TABLE IF NOT EXISTS verify
(
request_key VARCHAR(32) NOT NULL,
email_address VARCHAR(255) NOT NULL,
request_time DATETIME NOT NULL,
PRIMARY KEY(request_key),
UNIQUE(email_address)
);
EOB;
$sampleData = "INSERT INTO verify (request_key, email_address, request_time) VALUES ('DCE2D890895CF02','foo@bar.com','2001-01-01 01:01:01');";
 
 
// Populate Database
$adapter->query($tableSchema)->execute();
$adapter->query($sampleData)->execute();
 
// Check it
$resultSet = $adapter->query('SELECT * FROM ' . $adapter->platform->quoteIdentifier('verify'))->execute();
 
echo "Row Count: {$resultSet->count()}\n";
foreach ( $resultSet as $rowId=>$rowData ) {
echo "Row $rowId: ";
foreach ( $rowData as $columnName=>$columnValue ) {
echo "$columnName=$columnValue, ";
}
echo "\n";
}
echo "\n";

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.