index/src/Data/IDbResult.php

88 lines
2.4 KiB
PHP

<?php
// IDbResult.php
// Created: 2021-05-02
// Updated: 2022-02-16
namespace Index\Data;
use Index\AString;
use Index\ICloseable;
use Index\WString;
use Index\IO\Stream;
/**
* Represents a database result set.
*/
interface IDbResult extends ICloseable {
/**
* Fetches the next result set.
*
* @return bool true if the result set was loaded, false if no more results are available.
*/
function next(): bool;
/**
* Checks if a given index has a NULL value.
*
* @param int|string $index Target index.
* @return bool true if the value is null, false if not.
*/
function isNull(int|string $index): bool;
/**
* Gets the value from the target index without any additional casting.
*
* @param int|string $index Target index.
* @return mixed Target value.
*/
function getValue(int|string $index): mixed;
/**
* Gets the value from the target index cast as a native string.
*
* @param int|string $index Target index.
* @return string Returns a string of the value.
*/
function getString(int|string $index): string;
/**
* Gets the value from the target index cast as an ASCII string.
*
* @param int|string $index Target index.
* @return AString Returns an AString of the value.
*/
function getAString(int|string $index): AString;
/**
* Gets the value from the target index cast as a multi-byte string.
*
* @param int|string $index Target index.
* @param string $encoding Encoding of the string.
* @return WString Returns an WString of the value.
*/
function getWString(int|string $index, string $encoding): WString;
/**
* Gets the value from the target index cast as an integer.
*
* @param int|string $index Target index.
* @return int Returns the value cast to an integer.
*/
function getInteger(int|string $index): int;
/**
* Gets the value from the target index cast as a floating point number.
*
* @param int|string $index Target index.
* @return float Returns the value cast to a floating point number.
*/
function getFloat(int|string $index): float;
/**
* Gets the value from the target index as a Stream.
*
* @param int|string $index Target index.
* @return ?Stream A Stream if data is available, null if not.
*/
function getStream(int|string $index): ?Stream;
}