cubrid_execute
(PECL CUBRID >= 8.3.0)
cubrid_execute — Execute a prepared SQL statement
Описание
$conn_identifier
, string $sql
[, int $option
] )$request_identifier
[, int $option
] )
The cubrid_execute() function is used to execute the
given SQL statement. It executes the query by using
conn_identifier
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
cubrid_execute() function is used to execute the
prepared statement by means of cubrid_prepare() and
cubrid_bind(). At this time, you need to specify
arguments of request_identifier
and
option
.
The option
is used to determine whether to get OID
after query execution and whether to execute the query in synchronous or
asynchronous mode. CUBRID_INCLUDE_OID and CUBRID_ASYNC (or
CUBRID_EXEC_QUERY_ALL 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 CUBRID_EXEC_QUERY_ALL is set, a synchronous
mode (sync_mode) is used to retrieve query results, and in such cases the
following rules are applied:
- The return value is the result of the first query.
- If an error occurs in any query, the execution is processed as a failure.
- In a query composed of q1 q2 q3, if an error occurs in q2 after q1 succeeds the execution, the result of q1 remains valid. That is, the previous successful query executions are not rolled back when an error occurs.
- If a query is executed successfully, the result of the second query can be obtained using cubrid_next_result().
If the first argument is request_identifier
to
execute the cubrid_prepare() function, you can specify
an option, CUBRID_ASYNC only.
Список параметров
-
conn_identifier
-
Connection identifier.
-
sql
-
SQL to be executed.
-
option
-
Query execution option CUBRID_INCLUDE_OID, CUBRID_ASYNC, CUBRID_EXEC_QUERY_ALL.
-
request_identifier
-
cubrid_prepare() identifier.
Возвращаемые значения
Request identifier, when process is successful and first param is
conn_identifier; TRUE
, when process is successful and first argument is
request_identifier.
FALSE
, when process is unsuccessful.
Список изменений
Версия | Описание |
---|---|
8.4.0 | Add new option CUBRID_EXEC_QUERY_ALL. |
Примеры
Пример #1 cubrid_execute() 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() - Prepare a SQL statement for execution
- cubrid_bind() - Bind variables to a prepared statement as parameters
- cubrid_next_result() - Get result of next query when executing multiple SQL statements
- cubrid_close_request() - Close the request handle
- cubrid_commit() - Commit a transaction
- cubrid_rollback() - Roll back a transaction
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- CUBRID
- cubrid_bind
- cubrid_close_prepare
- cubrid_close_request
- cubrid_col_get
- cubrid_col_size
- cubrid_column_names
- cubrid_column_types
- cubrid_commit
- cubrid_connect_with_url
- cubrid_connect
- cubrid_current_oid
- cubrid_disconnect
- cubrid_drop
- cubrid_error_code_facility
- cubrid_error_code
- cubrid_error_msg
- cubrid_execute
- cubrid_fetch
- cubrid_free_result
- cubrid_get_autocommit
- cubrid_get_charset
- cubrid_get_class_name
- cubrid_get_client_info
- cubrid_get_db_parameter
- cubrid_get_query_timeout
- cubrid_get_server_info
- cubrid_get
- cubrid_insert_id
- cubrid_is_instance
- cubrid_lob_close
- cubrid_lob_export
- cubrid_lob_get
- cubrid_lob_send
- cubrid_lob_size
- cubrid_lob2_bind
- cubrid_lob2_close
- cubrid_lob2_export
- cubrid_lob2_import
- cubrid_lob2_new
- cubrid_lob2_read
- cubrid_lob2_seek64
- cubrid_lob2_seek
- cubrid_lob2_size64
- cubrid_lob2_size
- cubrid_lob2_tell64
- cubrid_lob2_tell
- cubrid_lob2_write
- cubrid_lock_read
- cubrid_lock_write
- cubrid_move_cursor
- cubrid_next_result
- cubrid_num_cols
- cubrid_num_rows
- cubrid_pconnect_with_url
- cubrid_pconnect
- cubrid_prepare
- cubrid_put
- cubrid_rollback
- cubrid_schema
- cubrid_seq_drop
- cubrid_seq_insert
- cubrid_seq_put
- cubrid_set_add
- cubrid_set_autocommit
- cubrid_set_db_parameter
- cubrid_set_drop
- cubrid_set_query_timeout
- cubrid_version
Коментарии
404 Not Found