mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-09 03:01:18 +02:00
Coding conventions state one class per file (unless it uses an _ to indicate related classes.
70 lines
1.3 KiB
PHP
70 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* A result-set from a MySQL database.
|
|
*
|
|
* @package framework
|
|
* @subpackage model
|
|
*/
|
|
class MySQLQuery extends SS_Query {
|
|
|
|
/**
|
|
* The MySQLDatabase object that created this result set.
|
|
* @var MySQLDatabase
|
|
*/
|
|
protected $database;
|
|
|
|
/**
|
|
* The internal MySQL handle that points to the result set.
|
|
* @var resource
|
|
*/
|
|
protected $handle;
|
|
|
|
/**
|
|
* Hook the result-set given into a Query class, suitable for use by
|
|
* SilverStripe.
|
|
*
|
|
* @param database $database The database object that created this query.
|
|
* @param handle $handle the internal mysql handle that is points to the resultset.
|
|
*/
|
|
public function __construct(MySQLDatabase $database, $handle) {
|
|
$this->database = $database;
|
|
$this->handle = $handle;
|
|
}
|
|
|
|
public function __destruct() {
|
|
if(is_object($this->handle)) {
|
|
$this->handle->free();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function seek($row) {
|
|
if(is_object($this->handle)) {
|
|
return $this->handle->data_seek($row);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function numRecords() {
|
|
if(is_object($this->handle)) {
|
|
return $this->handle->num_rows;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function nextRecord() {
|
|
if(is_object($this->handle) && ($data = $this->handle->fetch_assoc())) {
|
|
return $data;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|