Command
extends Command
in package
Represents a final database command, extending SqlCommand.
This class provides functionality for executing SQL commands and preparing statements with parameters. It inherits properties and methods from the SqlCommand class.
Table of Contents
Properties
- $connection : IConnection|null
- $page : int
- $pagesize : int
- $params : array<string|int, mixed>|null
- $query : string
- $type : string
- $_commandtext : string
- The command text.
- $_connection : IConnection|null
- The database connection associated with the command.
- $_page : int
- The current page number.
- $_pagesize : int
- The page size for pagination.
- $_params : array<string|int, mixed>|null
- The parameters for the command.
Methods
- __construct() : mixed
- Constructs a new Command object.
- __get() : mixed
- Magic method to get properties dynamically.
- __set() : void
- Magic method to set properties dynamically.
- ExecuteNonQuery() : QueryInfo
- Executes the command and returns query information.
- ExecuteReader() : IDataReader
- Executes the command and returns a data reader.
- PrepareQueryString() : string
- Prepares the query string with pagination and other necessary adjustments.
- _prepareStatement() : mysqli_stmt
- Prepares a statement with parameters.
Properties
$connection read-only
public
IConnection|null
$connection
The database connection associated with the command.
$page read-only
public
int
$page
The current page number.
$pagesize read-only
public
int
$pagesize
The page size for pagination.
$params read-only
public
array<string|int, mixed>|null
$params
The parameters for the command.
$query read-only
public
string
$query
The command text.
$type read-only
public
string
$type
The type of the command (e.g., SELECT, INSERT, UPDATE, DELETE).
$_commandtext
The command text.
protected
string
$_commandtext
= ''
$_connection
The database connection associated with the command.
protected
IConnection|null
$_connection
= null
$_page
The current page number.
protected
int
$_page
= -1
$_pagesize
The page size for pagination.
protected
int
$_pagesize
= 10
$_params
The parameters for the command.
protected
array<string|int, mixed>|null
$_params
= null
Methods
__construct()
Constructs a new Command object.
public
__construct([string $commandtext = '' ][, IConnection|null $connection = null ]) : mixed
Parameters
- $commandtext : string = ''
-
The command text.
- $connection : IConnection|null = null
-
(optional) The database connection. Default is null.
__get()
Magic method to get properties dynamically.
public
__get(string $property) : mixed
Parameters
- $property : string
-
The name of the property.
Return values
mixed —The value of the property, or null if the property does not exist.
__set()
Magic method to set properties dynamically.
public
__set(string $property, mixed $value) : void
Parameters
- $property : string
-
The name of the property.
- $value : mixed
-
The value to set.
ExecuteNonQuery()
Executes the command and returns query information.
public
ExecuteNonQuery([string|null $dummy = null ]) : QueryInfo
Parameters
- $dummy : string|null = null
-
(Unused parameter) Dummy parameter for compatibility. Default is null.
Tags
Return values
QueryInfo —The query information.
ExecuteReader()
Executes the command and returns a data reader.
public
ExecuteReader([bool $info = true ]) : IDataReader
Parameters
- $info : bool = true
-
Whether to execute a query to obtain the affected variable. Default is true.
Tags
Return values
IDataReader —The data reader.
PrepareQueryString()
Prepares the query string with pagination and other necessary adjustments.
public
PrepareQueryString() : string
Return values
string —The prepared query string.
_prepareStatement()
Prepares a statement with parameters.
private
_prepareStatement(string $query) : mysqli_stmt
Parameters
- $query : string
-
The query with placeholders for parameters.
Tags
Return values
mysqli_stmt —The prepared statement.