cubrid_fetch
(PECL CUBRID >= 8.3.0)
cubrid_fetch — Fetch the next row from a result set
Description
The cubrid_fetch() function is used to get a single row from the query result. The cursor automatically moves to the next row after getting the result.
Parameters
-
result
-
result
comes from a call to cubrid_execute() -
type
-
Array type of the fetched result CUBRID_NUM, CUBRID_ASSOC, CUBRID_BOTH, CUBRID_OBJECT. If you want to operate the lob object, you can use CUBRID_LOB.
Return Values
Result array or object, when process is successful.
FALSE
, when there are no more rows; NULL, when process is unsuccessful.
The result can be received either as an array or as an object, and you can decide which data type to use by setting the type
argument. The type
variable can be set to one of the following values:
- CUBRID_NUM : Numerical array (0-based)
- CUBRID_ASSOC : Associative array
- CUBRID_BOTH : Numerical & Associative array (default)
- CUBRID_OBJECT : object that has the attribute name as the column name of query result
When type
argument is omitted, the result will be received using CUBRID_BOTH option as default. When you want to receive query result in object data type, the column name of the result must obey the naming rules for identifiers in PHP. For example, column name such as "count(*)" cannot be received in object type.
Examples
Example #1 cubrid_fetch() example
<?php
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT * FROM stadium WHERE nation_code='GRE' AND seats > 10000");
printf("%-40s %-10s %-6s %-20s\n", "name", "area", "seats", "address");
while ($row = cubrid_fetch($req)) {
printf("%-40s %-10s %-6s %-20s\n",
$row["name"], $row["area"], $row["seats"], $row["address"]);
}
// if you want to operate lob object, you can use cubrid_fetch($req, CUBRID_LOB)
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
The above example will output:
name area seats address Panathinaiko Stadium 86300.00 50000 Athens, Greece Olympic Stadium 54700.00 13000 Athens, Greece Olympic Indoor Hall 34100.00 18800 Athens, Greece Olympic Hall 52400.00 21000 Athens, Greece Olympic Aquatic Centre 42500.00 11500 Athens, Greece Markopoulo Olympic Equestrian Centre 64000.00 15000 Markopoulo, Athens, Greece Faliro Coastal Zone Olympic Complex 34650.00 12171 Faliro, Athens, Greece Athens Olympic Stadium 120400.00 71030 Maroussi, Athens, Greece Ano Liossia 34000.00 12000 Ano Liosia, Athens, Greece
See Also
- cubrid_execute() - Execute a prepared SQL statement
- cubrid_fetch_array() - Fetch a result row as an associative array, a numeric array, or both
- cubrid_fetch_row() - Return a numerical array with the values of the current row
- cubrid_fetch_assoc() - Return the associative array that corresponds to the fetched row
- cubrid_fetch_object() - Fetche the next row and returns it as an object
- 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