Fetches binary data's from BLOB field type.
Warning: to read a blob it is necessary to be in transaction. To write a blob, file must also be journalized.
string i5_ getblob (resource result, int Field_Index)
or
string i5_ getblob (resource result, string Field_ Name)
Parameters
result |
File ID |
Field_Index |
BLOB field index |
Field_ Name |
BLOB field name |
Return
Returns string with BLOB binary chain or FALSE in case of fault.
I5_ERR_PHP_HDLDFT |
256 |
No default connection found. |
I5_ERR_PHP_OPTIONSTYPE |
259 |
The type of " I5_OPTIONS_ALIAS" option must be x and not x |
I5_ERR_PHP_OPTIONSNUMBER |
260 |
Option number -1 is unknown. |
I5_ERR_PHP_TYPEPARAM |
262 |
Type of element x in parameter -1 must be y. Type z was provided. |
I5_ERR_PHP_SPOOL_FILE_FOPEN |
269 |
Internal Error on temporary file(x); code error: -1. |
Details
i5_getblob function applies to SELECT type (i5_query or i5_execute) requests containing one or more BLOB type fields.
In the same way that i5_result function reads a unique field value, i5_getblob function allows to fetch binary data.
The blob field value is read from the current record fetched by a previous call to i5_fetch_xxx function.
If field name or position do not match with BLOB type, i5_getblob returns FALSE.
Example
i5_transaction(I5_ISOLEVEL_CHG);
$sql = "SELECT photo FROM CRD.IMBLO2;";
$res = i5_query($sql);
if($res === false){
print_r("error : ".i5_errormsg().'<br/>');
}
$line = i5_fetch_row($res);
if($line === false){
print_r("error : ".i5_errormsg().'<br/>');
}
echo 'line<br/>';
// $blob_data[] = i5_getblob($res, $line[0]);
// $blob_data[] = i5_getblob($res, "photo");
$blob_data[] = i5_getblob($res, 0);
if($blob_data === false){
print_r("error : ".i5_errormsg().'<br/>');
}
else
{
var_dump($blob_data);
echo 'blob_data<br/>';
}
i5_rollback();
See also