Applicable to PHP version (PHP 8 >= 8.2.0)
illustrate
Object-oriented style
public mysqli::execute_query(string $query, ?array $params = null): mysqli_result|bool
Process style
mysqli_execute_query(mysqli $mysql, string $query, ?array $params = null): mysqli_result|bool
Prepare SQL queries, bind parameters and execute queries. The mysqli::execute_query() method is a shortcut to mysqli::prepare(), mysqli_stmt::bind_param(), mysqli_stmt::execute() and mysqli_stmt::get_result().Notice
If the statement passed to mysqli_execute_query() is longer than the server's max_allowed_packet, the returned error code will vary depending on the operating system. The behavior is as follows:
Return error code 1153 on Linux. The error message means that the resulting packet is larger than the max_allowed_packet bytes.
Returns error code 2006 on Windows. This error message indicates that the server has disappeared.
parameter
mysql
Procedural style only: a mysqli object returned by mysqli_connect() or mysqli_init().
query
Query, as a string. It must consist of a single SQL statement.
SQL statements can contain zero or more parameter marks represented by question marks (?) characters in appropriate locations.
Notice:
These tags are only legal in certain places in SQL statements. For example, they are allowed to be used in the VALUES() list of the INSERT statement (specifying column values for a row), or they are allowed to specify comparison values when compared with columns in the WHERE clause. However, they are not allowed to be used for identifiers (such as table or column names).
params
An optional list array with as many elements as the number of bound parameters in the SQL statement being executed. Each value is treated as a string.