index/src/Data/IDbStatement.php

54 lines
1.2 KiB
PHP

<?php
// IDbStatement.php
// Created: 2021-05-02
// Updated: 2022-02-16
namespace Index\Data;
use Index\ICloseable;
/**
* Represents a prepared database statement.
*/
interface IDbStatement extends ICloseable {
/**
* Returns how many parameters there are.
*
* @return int Number of parameters.
*/
function getParameterCount(): int;
/**
* Assigns a value to a parameter.
*
* @param int $ordinal Index of the target parameter.
* @param mixed $value Value to assign to the parameter.
* @param int $type Type of the value, if left to DbType::AUTO DbTools::detectType will be used on $value.
*/
function addParameter(int $ordinal, mixed $value, int $type = DbType::AUTO): void;
/**
* Gets the result after execution.
*
* @return IDbResult Instance of an implementation of IDbResult.
*/
function getResult(): IDbResult;
/**
* Returns the ID of the last inserted row.
*
* @return int|string Last inserted ID.
*/
function getLastInsertId(): int|string;
/**
* Executes this statement.
*/
function execute(): void;
/**
* Resets this statement for reuse.
*/
function reset(): void;
}