602SQL Documentation Index  



mixed wb_result( resource cursor, integer column_number )
mixed wb_result( resource cursor, string column_name )


Identifier of a cursor returned by the wb_exec or wb_psql_execute function.
Designation of the desired column by ordinal number (columns are numbered from 1).
Designation of the desired column by name (not case-sensitive)


This function provides a basic method for getting data from an open cursor. Works with the current record. In order to set the current record, use the wb_fetch_row or wb_data_seek function.


Value of the specified attribute in the current record. See Passing values from 602SQL to PHP. FALSE is returned if an error occurs, and the error is reported by the standard mechanisms of PHP.

WARNING: If you read the value of the variable-length type column (BLOB, CLOB, etc.), only the beginning segment of the column value will be read (the length of the segment is set by the global parameter longreadlen, see also Manipulating variable-length types in PHP).

WARNING: If you read the value of the BOOLEAN type column, the PHP values may be only TRUE or FALSE. NULL value is read as FALSE! In order to recognize the NULL value you must also call the is_null() PHP function.


A typical way to reading data from a cursor is from a loop:

$cursor=wb_exec($connection, "SELECT ID,order_date FROM...");
while (wb_fetch_row($cursor))
    echo( wb_result($cursor, 1).": <i>".wb_result($cursor, 2)."</i><br>");
  //echo( wb_result($cursor, "id").": <i>".wb_result($cursor, "order_date")."</i><br>");  


Reading a CLOB value (in the WB_LOBMODE_DIRECT mode):

    "SELECT clob_column,CHAR_LENGTH(clob_column) AS clob_length FROM my_table");
while( wb_fetch_row($cursor) )
    // get the CLOB length
    // set the INI parameter wb_longreadlen so I can read the whole CLOB
    // read the CLOB into the PHP variable $clob