cubrid_execute
cubrid_execute
Execute a prepared SQL statement
resource **cubrid_execute** resource $conn_identifier string $sql int $option
bool **cubrid_execute** resource $request_identifier int $option
The function is used to execute the
given SQL statement. It executes the query by using
and SQL, and then returns the
request identifier created. It is used for simple execution of query,
where the parameter binding is not needed. In addition, the
function is used to execute the
prepared statement by means of and
. At this time, you need to specify
arguments of and
.
`cubrid_execute``conn_identifier``cubrid_execute``cubrid_prepare``cubrid_bind``request_identifier``option`
The is used to determine whether to get OID
after query execution and whether to execute the query in synchronous or
asynchronous mode. and (or
if you want to execute multiple SQL statements) can
be specified by using a bitwise OR operator. If not specified, neither of
them isselected. If the flag is set, a synchronous
mode (sync_mode) is used to retrieve query results, and in such cases the
following rules are applied:
`option``CUBRID_INCLUDE_OID``CUBRID_ASYNC``CUBRID_EXEC_QUERY_ALL``CUBRID_EXEC_QUERY_ALL`
cubrid_next_result
If the first argument is to
execute the function, you can specify
an option, only.
request_identifier``cubrid_prepare``CUBRID_ASYNC
conn_identifierConnection identifier.
sqlSQL to be executed.
optionQuery execution option , , .CUBRID_INCLUDE_OID``CUBRID_ASYNC``CUBRID_EXEC_QUERY_ALL
request_identifier identifier.cubrid_prepare
Request identifier, when process is successful and first param is conn_identifier; true, when process is successful and first argument is request_identifier,return.falseforfailure.
Voorbeeld: example
<?php
$conn = cubrid_connect("localhost", 33000, "demodb");
$result = cubrid_execute($conn, "SELECT code FROM event WHERE name='100m Butterfly' and gender='M'", CUBRID_ASYNC);
$row = cubrid_fetch_array($result, CUBRID_ASSOC);
$event_code = $row["code"];
cubrid_close_request($result);
$history_req = cubrid_prepare($conn, "SELECT * FROM history WHERE event_code=?");
cubrid_bind($history_req, 1, $event_code, "number");
cubrid_execute($history_req);
printf("%-20s %-9s %-10s %-5s\n", "athlete", "host_year", "score", "unit");
while ($row = cubrid_fetch_array($history_req, CUBRID_ASSOC)) {
printf("%-20s %-9s %-10s %-5s\n",
$row["athlete"], $row["host_year"], $row["score"], $row["unit"]);
}
cubrid_close_request($history_req);
cubrid_disconnect($conn);
?>
athlete host_year score unit
Phelps Michael 2004 51.25 time
cubrid_prepare``cubrid_bind``cubrid_next_result``cubrid_close_request``cubrid_commit``cubrid_rollback