LibSQLStatement
class is responsible for managing SQL statement preparation, execution, and result retrieval. It provides methods to bind parameters, execute statements, and retrieve data from the database.
Methods
bindNamed
Binds a value to a named parameter in the prepared statement.
Parameters
array<string, mixed> $parameters
: The parameters to bind.
Returns
- (void)
Example
bindPositional
Binds a value to a positional parameter in the prepared statement.
Parameters
array<mixed> $parameters
: The parameter index (starting at 1) or name to bind to.
Returns
- (void)
Example
query
Executes the prepared SQL statement and retrieves the result set.
Parameters
array|null $parameters
(optional): Parameters to bind to the statement before execution.
Returns
- (LibSQLResult): The result set of the query.
Example
execute
Executes the prepared statement with given parameters.
Parameters
array|null $parameters
(optional): Parameters to bind to the statement before execution.
Returns
- (int): The number of rows affected by the statement.
Example
reset
Resets the prepared SQL statement so it can be executed again.
Returns
- (void)
Example
parameterCount
Gets the number of parameters in the prepared statement.
Returns
- (int): The number of total parameters in the prepared statement.
Example
parameterName
Gets the name of a parameter by index (1-based index).
Parameters
int $idx
: The index of the parameter.
Returns
- (string): The name of the parameter.
Example
columns
Gets the column names of the result set.
Returns
- (array): The prepared column names and details.