Created
May 11, 2012 13:36
-
-
Save adamlundrigan/2659662 to your computer and use it in GitHub Desktop.
Zend\Db\Adapter\Driver\Pdo\Result not returning row count?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ php sqlite_count.php | |
Row Count: 0 | |
Row 0: request_key=DCE2D890895CF02, [email protected], request_time=2001-01-01 01:01:01, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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','[email protected]','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