index/src/Data/MariaDB/MariaDBResultNative.php

41 lines
962 B
PHP

<?php
// MariaDBResultNative.php
// Created: 2021-05-02
// Updated: 2021-05-04
namespace Index\Data\MariaDB;
use mysqli_result;
use mysqli_stmt;
use Index\Data\QueryExecuteException;
/**
* Implementation of MariaDBResult for mysqlnd.
*
* @internal
*/
class MariaDBResultNative extends MariaDBResult {
public function __construct(mysqli_stmt|mysqli_result $result) {
if($result instanceof mysqli_stmt) {
$_result = $result->get_result();
if($_result === false)
throw new QueryExecuteException($result->error, $result->errno);
$result = $_result;
}
parent::__construct($result);
}
public function next(): bool {
$result = $this->result->fetch_array(MYSQLI_BOTH);
if($result === null)
return false;
$this->currentRow = $result;
return true;
}
public function close(): void {
$this->result->close();
}
}