mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
8dd644d25d
Namespace all templates Move difflib and BBCodeParser2 to thirdparty Remove deprecated API marked for removal in 4.0
57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace SilverStripe\ORM\Connect;
|
|
|
|
/**
|
|
* A result-set from a MySQL database (using MySQLiConnector)
|
|
*/
|
|
class MySQLQuery extends SS_Query {
|
|
|
|
/**
|
|
* The internal MySQL handle that points to the result set.
|
|
* Select queries will have mysqli_result as a value.
|
|
* Non-select queries will not
|
|
*
|
|
* @var mixed
|
|
*/
|
|
protected $handle;
|
|
|
|
/**
|
|
* Hook the result-set given into a Query class, suitable for use by SilverStripe.
|
|
*
|
|
* @param MySQLiConnector $database The database object that created this query.
|
|
* @param mixed $handle the internal mysql handle that is points to the resultset.
|
|
* Non-mysqli_result values could be given for non-select queries (e.g. true)
|
|
*/
|
|
public function __construct($database, $handle) {
|
|
$this->handle = $handle;
|
|
}
|
|
|
|
public function __destruct() {
|
|
if (is_object($this->handle)) $this->handle->free();
|
|
}
|
|
|
|
public function seek($row) {
|
|
if (is_object($this->handle)) {
|
|
return $this->handle->data_seek($row);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public function numRecords() {
|
|
if (is_object($this->handle)) {
|
|
return $this->handle->num_rows;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public function nextRecord() {
|
|
if (is_object($this->handle) && ($data = $this->handle->fetch_assoc())) {
|
|
return $data;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|