silverstripe-postgresql/code/PostgreSQLQuery.php
2015-12-18 07:18:01 +13:00

50 lines
1.0 KiB
PHP

<?php
/**
* A result-set from a PostgreSQL database.
*
* @package sapphire
* @subpackage model
*/
class PostgreSQLQuery extends SS_Query
{
/**
* The internal Postgres handle that points to the result set.
* @var resource
*/
private $handle;
/**
* Hook the result-set given into a Query class, suitable for use by sapphire.
* @param database The database object that created this query.
* @param handle the internal Postgres handle that is points to the resultset.
*/
public function __construct($handle)
{
$this->handle = $handle;
}
public function __destruct()
{
if (is_resource($this->handle)) {
pg_free_result($this->handle);
}
}
public function seek($row)
{
return pg_result_seek($this->handle, $row);
}
public function numRecords()
{
return pg_num_rows($this->handle);
}
public function nextRecord()
{
return pg_fetch_assoc($this->handle);
}
}