Skip to content

@adamlundrigan /sqlite_count.output
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Zend\Db\Adapter\Driver\Pdo\Result not returning row count?
$ 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,
<?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";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.