diff --git a/functions/fbsql.xml b/functions/fbsql.xml index bc375c20c0..5a68913abd 100644 --- a/functions/fbsql.xml +++ b/functions/fbsql.xml @@ -1,5 +1,5 @@ - + FrontBase functions FrontBase @@ -201,7 +201,7 @@ - See also: fbsql_connect, and + See also: fbsql_connect and fbsql_pconnect. @@ -305,7 +305,7 @@ See also - fbsql_pconnect, and + fbsql_pconnect and fbsql_close. @@ -388,7 +388,7 @@ or die ("Could not connect"); $filename = "blobfile.bin"; $fp = fopen($filename, "rb"); - $blobdata = fread($fp, file_size($filename)); + $blobdata = fread($fp, filesize($filename)); fclose($fp); $blobHandle = fbsql_create_blob($blobdata, $link); @@ -398,8 +398,11 @@ ?> - - See also: fbsql_create_clob. + See also: + fbsql_create_clob, + fbsql_read_blob, + fbsql_read_clob, + fbsql_set_lob_mode @@ -438,7 +441,7 @@ or die ("Could not connect"); $filename = "clob_file.txt"; $fp = fopen($filename, "rb"); - $clobdata = fread($fp, file_size($filename)); + $clobdata = fread($fp, filesize($filename)); fclose($fp); $clobHandle = fbsql_create_clob($clobdata, $link); @@ -448,8 +451,11 @@ ?> - - See also: fbsql_create_blob. + See also: + fbsql_create_blob, + fbsql_read_blob, + fbsql_read_clob, + fbsql_set_lob_mode @@ -1056,7 +1062,7 @@ fbsql_free_result ($result); fbsql_fetch_lengths stores the lengths of each result column in the last row returned by fbsql_fetch_row, - fbsql_fetch_array, and + fbsql_fetch_array and fbsql_fetch_object in an array, starting at offset 0. @@ -1159,7 +1165,7 @@ fbsql_free_result ($result); See also: fbsql_fetch_array, fbsql_fetch_object, fbsql_data_seek, - fbsql_fetch_lengths, and + fbsql_fetch_lengths and fbsql_result. @@ -1529,7 +1535,7 @@ database3 the table name. A result pointer is returned which can be used with fbsql_field_flags, fbsql_field_len, - fbsql_field_name, and + fbsql_field_name and fbsql_field_type. @@ -1862,12 +1868,134 @@ $result = fbsql_query ("SELECT my_col FROM my_tbl") fbsql_db_query, fbsql_free_result, fbsql_result, - fbsql_select_db, and + fbsql_select_db and fbsql_connect. + + + fbsql_read_blob + Read a BLOB from the database + + + Description + + + string fbsql_read_blob + string blob_handle + resource + + link_identifier + + + + + + Returns: A string containing the BLOB specified by blob_handle. + + + fbsql_read_blob reads BLOB data from the database. + If a select statement contains BLOB and/or BLOB columns FrontBase + will return the data directly when data is fetched. This default + behavior can be changed with fbsql_set_lob_mode so + the fetch functions will return handles to BLOB and CLOB data. + If a handle is fetched a user must call fbsql_read_blob + to get the actual BLOB data from the database. + + + <function>fbsql_read_blob</function> example + +<?php + $link = fbsql_pconnect ("localhost", "_SYSTEM", "secret") + or die ("Could not connect"); + $sql = "SELECT BLOB_COLUMN FROM BLOB_TABLE;"; + $rs = fbsql_query($sql, $link); + $row_data = fbsql_fetch_row($rs); + // $row_data[0] will now contain the blob data for teh first row + fbsql_free_result($rs); + + $rs = fbsql_query($sql, $link); + fbsql_set_lob_mode($rs, FBSQL_LOB_HANDLE); + $row_data = fbsql_fetch_row($rs); + // $row_data[0] will now contain a handle to the BLOB data in the first row + $blob_data = fbsql_read_blob($row_data[0]); + fbsql_free_result($rs); + +?> + + + See also: + fbsql_create_blob, + fbsql_read_blob, + fbsql_read_clob, + fbsql_set_lob_mode + + + + + + + fbsql_read_clob + Read a CLOB from the database + + + Description + + + string fbsql_read_clob + string clob_handle + resource + + link_identifier + + + + + + Returns: A string containing the CLOB specified by clob_handle. + + + fbsql_read_clob reads CLOB data from the database. + If a select statement contains BLOB and/or CLOB columns FrontBase + will return the data directly when data is fetched. This default + behavior can be changed with fbsql_set_lob_mode so + the fetch functions will return handles to BLOB and CLOB data. + If a handle is fetched a user must call fbsql_read_clob + to get the actual CLOB data from the database. + + + <function>fbsql_read_clob</function> example + +<?php + $link = fbsql_pconnect ("localhost", "_SYSTEM", "secret") + or die ("Could not connect"); + $sql = "SELECT CLOB_COLUMN FROM CLOB_TABLE;"; + $rs = fbsql_query($sql, $link); + $row_data = fbsql_fetch_row($rs); + // $row_data[0] will now contain the clob data for teh first row + fbsql_free_result($rs); + + $rs = fbsql_query($sql, $link); + fbsql_set_lob_mode($rs, FBSQL_LOB_HANDLE); + $row_data = fbsql_fetch_row($rs); + // $row_data[0] will now contain a handle to the CLOB data in the first row + $clob_data = fbsql_read_clob($row_data[0]); + fbsql_free_result($rs); + +?> + + + See also: + fbsql_create_blob, + fbsql_read_blob, + fbsql_read_clob, + fbsql_set_lob_mode + + + + fbsql_result @@ -1911,7 +2039,7 @@ $result = fbsql_query ("SELECT my_col FROM my_tbl") Recommended high-performance alternatives: fbsql_fetch_row, - fbsql_fetch_array, and + fbsql_fetch_array and fbsql_fetch_object. @@ -1949,6 +2077,62 @@ $result = fbsql_query ("SELECT my_col FROM my_tbl") + + + fbsql_set_lob_mode + Set the LOB retreive mode for a FrontBase result set + + + Description + + + bool fbsql_set_lob_mode + resource result + string database_name + + + + Returns: &true; on success, &false; on error. + + + fbsql_set_lob_mode sets the mode for + retreiving LOB data from the database. When BLOB and CLOB data + is stored in FrontBase it can be stored direct or indirect. + Direct stored LOB data will allways be fetched no matter the setting + of the lob mode. If the LOB data is less than 24 bytes it will allways + be stored directly. + + + + FBSQL_LOB_DIRECT - LOB data is retreived directly. When data is + fetched from the database with fbsql_fetch_row, + and other fetch functions, all CLOB and BLOB columns will be returned + as ordinary coluimns. + This is the default value on a new FrontBase resutl. + + + + + FBSQL_LOB_HANDLE - LOB data is retreived as handles to the data. + When data is fetched from the database with fbsql_fetch_row + , and other fetch functions, LOB data will be returned as + a handle to the data if the data is stored indirect or the data if it + is stored direct. + If a handle is returned it will be a 27 byte string formated as + "@'000000000000000000000000'". + + + + + See also: + fbsql_create_blob, + fbsql_create_clob, + fbsql_read_blob and + fbsql_read_clob + + + + fbsql_select_db @@ -1992,7 +2176,7 @@ $result = fbsql_query ("SELECT my_col FROM my_tbl") See also: fbsql_connect, - fbsql_pconnect, and + fbsql_pconnect and fbsql_query.