Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cubrid_fetch_array(3) [php man page]

CUBRID_FETCH_ARRAY(3)							 1						     CUBRID_FETCH_ARRAY(3)

cubrid_fetch_array - Fetch a result row as an associative array, a numeric array, or both

SYNOPSIS
array cubrid_fetch_array (resource $result, [int $type = CUBRID_BOTH]) DESCRIPTION
The cubrid_fetch_array(3) function is used to get a single row from the query result and returns an array. The cursor automatically moves to the next row after getting the result. PARAMETERS
o $result -$Result comes from a call to cubrid_execute(3) o $type -Array type of the fetched result CUBRID_NUM, CUBRID_ASSOC, CUBRID_BOTH. If you need to operate the lob object, you can use CUBRID_LOB. RETURN VALUES
Returns an array of strings that corresponds to the fetched row, when process is successful. FALSE, when there are no more rows; NULL, when process is unsuccessful. The type of returned array depends on how type is defined. By using CUBRID_BOTH (default), you'll get an array with both associative and number indices, and you can decide which data type to use by setting the $type argument. The $type variable can be set to one of the fol- lowing values: oCUBRID_NUM : Numerical array (0-based) oCUBRID_ASSOC : Associative array oCUBRID_BOTH : Numerical & Associative array (default) EXAMPLES
Example #1 cubrid_fetch_array(3) example <?php $conn = cubrid_connect("localhost", 33000, "demodb"); $req = cubrid_execute($conn, "SELECT name,area,seats,address FROM stadium WHERE nation_code='GRE' AND seats > 10000"); printf("%-40s %-10s %-6s %-20s ", "name", "area", "seats", "address"); while ($row = cubrid_fetch_array($req, CUBRID_NUM)) { printf("%-40s %-10s %-6s %-20s ", $row[0], $row[1], $row[2], $row[3]); } // if you want to operate LOB object, you can use cubrid_fetch_array($req, CUBRID_NUM | 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(3), cubrid_fetch(3), cubrid_fetch_row(3), cubrid_fetch_assoc(3), cubrid_fetch_object(3). PHP Documentation Group CUBRID_FETCH_ARRAY(3)

Check Out this Related Man Page

CUBRID_EXECUTE(3)							 1							 CUBRID_EXECUTE(3)

cubrid_execute - Execute a prepared SQL statement

SYNOPSIS
resource cubrid_execute (resource $conn_identifier, string $sql, [int $option]) DESCRIPTION
bool cubrid_execute (resource $request_identifier, [int $option]) The cubrid_execute(3) 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 addi- tion, the cubrid_execute(3) function is used to execute the prepared statement by means of cubrid_prepare(3) and cubrid_bind(3). 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: oThe return value is the result of the first query. o If an error occurs in any query, the execution is processed as a failure. o 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. o If a query is executed successfully, the result of the second query can be obtained using cubrid_next_result(3). If the first argument is $request_identifier to execute the cubrid_prepare(3) function, you can specify an option, CUBRID_ASYNC only. PARAMETERS
o $conn_identifier -Connection identifier. o $sql -SQL to be executed. o $option -Query execution option CUBRID_INCLUDE_OID, CUBRID_ASYNC, CUBRID_EXEC_QUERY_ALL. o $request_identifier -cubrid_prepare(3) identifier. RETURN VALUES
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. CHANGELOG
+--------+----------------------------------------+ |Version | | | | | | | Description | | | | +--------+----------------------------------------+ | 8.4.0 | | | | | | | Add new option CUBRID_EXEC_QUERY_ALL. | | | | +--------+----------------------------------------+ EXAMPLES
Example #1 cubrid_execute(3) 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 ", "athlete", "host_year", "score", "unit"); while ($row = cubrid_fetch_array($history_req, CUBRID_ASSOC)) { printf("%-20s %-9s %-10s %-5s ", $row["athlete"], $row["host_year"], $row["score"], $row["unit"]); } cubrid_close_request($history_req); cubrid_disconnect($conn); ?> The above example will output: athlete host_year score unit Phelps Michael 2004 51.25 time SEE ALSO
cubrid_prepare(3), cubrid_bind(3), cubrid_next_result(3), cubrid_close_request(3), cubrid_commit(3), cubrid_rollback(3). PHP Documentation Group CUBRID_EXECUTE(3)
Man Page