Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cubrid_fetch_assoc(3) [php man page]

CUBRID_FETCH_ASSOC(3)							 1						     CUBRID_FETCH_ASSOC(3)

cubrid_fetch_assoc - Return the associative array that corresponds to the fetched row

SYNOPSIS
array cubrid_fetch_assoc (resource $result, [int $type]) DESCRIPTION
This function returns the associative array, that corresponds to the fetched row, and then moves the internal data pointer ahead, or returns FALSE when the end is reached. PARAMETERS
o $result -$result comes from a call to cubrid_execute(3) o $type -Type can only be CUBRID_LOB, this parameter will be used only when you need to operate the lob object. RETURN VALUES
Associative array, when process is successful. FALSE, when there are no more rows; NULL, when process is unsuccessful. EXAMPLES
Example #1 cubrid_fetch_assoc(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_assoc($req)) { printf("%-40s %-10s %-6s %-20s ", $row["name"], $row["area"], $row["seats"], $row["address"]); } // if you want to operate LOB object, you can use cubrid_fetch_assoc($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(3), cubrid_fetch(3), cubrid_fetch_row(3), cubrid_fetch_array(3), cubrid_fetch_object(3). PHP Documentation Group CUBRID_FETCH_ASSOC(3)

Check Out this Related Man Page

CUBRID_BIND(3)								 1							    CUBRID_BIND(3)

cubrid_bind - Bind variables to a prepared statement as parameters

SYNOPSIS
bool cubrid_bind (resource $req_identifier, int $bind_index, mixed $bind_value, [string $bind_value_type]) DESCRIPTION
The cubrid_bind(3) function is used to bind values to a corresponding named or question mark placeholder in the SQL statement that was passed to cubrid_prepare(3). If $bind_value_type is not given, string will be the default. Note If the type of data to be bound is BLOB/CLOB, CUBRID will try to map the data as a PHP stream. If the actually bind value type is not stream, CUBRID will convert it to string, and use it as the full path and file name of a file on the client filesystem. If the type of data to be bound explicitly is ENUM, the $bind_value argument should be the enum element which is in string format. In CUBRID shard envrioment, the $bind_value_type must be included in the cubrid_bind function. The following table shows the types of substitute values. CUBRID Bind Date Types +----------------------+------------------------+---+ | Support | | | | | | | | | Bind Type | | | | | | | | Corresponding SQL Type | | | | | | +----------------------+------------------------+---+ | Supported | | | | | | | | | STRING | | | | | | | | CHAR, VARCHAR | | | | | | | | | | | |T{ NCHAR | | | | | | | | | NCHAR, NVARCHAR | | | | | | | | | | | |T{ BIT | | | | | | | | | BIT, VARBIT | | | | | | | | | | ||T{ NUMERIC or NUMBER | | | | | | | | | SHORT, INT, NUMERIC | | | | | | | | | | | |T{ FLOAT | | | | | | | | | FLOAT | | | | | | | | | | | |T{ DOUBLE | | | | | | | | | DOUBLE | | | | | | | | | | | |T{ TIME | | | | | | | | | TIME | | | | | | | | | | | |T{ DATE | | | | | | | | | DATE | | | | | | | | | | | |T{ TIMESTAMP | | | | | | | | | TIMESTAMP | | | | | | | | | | | |T{ OBJECT | | | | | | | | | OBJECT | | | | | | | | | | | |T{ ENUM | | | | | | | | | ENUM | | | | | | | | | | | |T{ BLOB | | | | | | | | | BLOB | | | | | | | | | | | |T{ CLOB | | | | | | | | | CLOB | | | | | | | | | | | |T{ NULL | | | | | | | | | NULL | | | | | | | Not supported | | | | | | | | | SET | | | | | | | | SET | | | | | | | | | | | |T{ MULTISET | | | | | | | | | MULTISET | | | | | | | | | | | |T{ SEQUENCE | | | | | | | | | SEQUENCE | | | | | | +----------------------+------------------------+---+ PARAMETERS
o $req_identifier -Request identifier as a result of cubrid_prepare(3). o $bind_index -Location of binding parameters. It starts with 1. o $bind_value -Actual value for binding. o $bind_value_type -A type of the value to bind. (It is omitted by default. Thus, the system internally uses string by default. However, you need to specify the exact type of the value as an argument when they are NCHAR, BIT, or BLOB/CLOB). RETURN VALUES
TRUE, when process is successful. FALSE, when process is unsuccessful. CHANGELOG
+--------+--------------------------------------+ |Version | | | | | | | Description | | | | +--------+--------------------------------------+ | 8.3.1 | | | | | | | Added BLOB/CLOB data types support. | | | | +--------+--------------------------------------+ EXAMPLES
Example #1 cubrid_bind(3) example <?php $conn = cubrid_connect("localhost", 33000, "demodb", "dba"); $result = cubrid_execute($conn, "SELECT code FROM event WHERE sports='Basketball' and gender='M'"); $row = cubrid_fetch_array($result, CUBRID_ASSOC); $event_code = $row["code"]; cubrid_close_request($result); $game_req = cubrid_prepare($conn, "SELECT athlete_code FROM game WHERE host_year=1992 and event_code=? and nation_code='USA'"); cubrid_bind($game_req, 1, $event_code, "number"); cubrid_execute($game_req); printf("--- Dream Team (1992 United States men's Olympic basketball team) --- "); while ($athlete_code = cubrid_fetch_array($game_req, CUBRID_NUM)) { $athlete_req = cubrid_prepare($conn, "SELECT name FROM athlete WHERE code=? AND nation_code='USA' AND event='Basketball' AND gender='M'"); cubrid_bind($athlete_req, 1, $athlete_code[0], "number"); cubrid_execute($athlete_req); $row = cubrid_fetch_assoc($athlete_req); printf("%s ", $row["name"]); } cubrid_close_request($game_req); cubrid_close_request($athlete_req); cubrid_disconnect($conn); ?> The above example will output: --- Dream Team (1992 United States men's Olympic basketball team) --- Stockton John Robinson David Pippen Scottie Mullin C. Malone Karl Laettner C. Jordan Michael Johnson Earvin Ewing Patrick Drexler Clyde Bird Larry Barkley Charles Example #2 cubrid_bind(3) BLOB/CLOB example <?php $con = cubrid_connect("localhost", 33000, "demodb", "dba", ""); if ($con) { cubrid_execute($con,"DROP TABLE if exists php_cubrid_lob_test"); cubrid_execute($con,"CREATE TABLE php_cubrid_lob_test (doc_content CLOB)"); $sql = "INSERT INTO php_cubrid_lob_test(doc_content) VALUES(?)"; $req = cubrid_prepare($con, $sql); $fp = fopen("book.txt", "rb"); cubrid_bind($req, 1, $fp, "clob"); cubrid_execute($req); } ?> Example #3 cubrid_bind(3) BLOB/CLOB example <?php $con = cubrid_connect("localhost", 33000, "demodb", "dba", ""); if ($con) { cubrid_execute($con,"DROP TABLE if exists php_cubrid_lob_test"); cubrid_execute($con,"CREATE TABLE php_cubrid_lob_test (image BLOB)"); $sql = "INSERT INTO php_cubrid_lob_test(image) VALUES(?)"; $req = cubrid_prepare($con, $sql); cubrid_bind($req, 1, "cubrid_logo.png", "blob"); cubrid_execute($req); } ?> SEE ALSO
cubrid_execute(3), cubrid_prepare(3). PHP Documentation Group CUBRID_BIND(3)
Man Page