Writes binary data in a BLOB type field.
bool i5_ setblob (resource stmt, int position, string blob)
or
bool i5_ setblob (resource stmt, string parmName, string blob)
Parameters
stmt |
Parameterized request ID |
|
position |
Parameter index |
|
parmName |
Parameter name |
|
blob |
Binary chain content |
Return
True if OK, false if failed.
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. |
Details
Writes a character’s chain containing binary data's in a type BLOB file.
This function only applies to parameterized requests resources and is used the same way as i5_setparam function.
Warning, a blob can only be read in a transaction. To write a blob, a journalized file is also required.
Example
$ret = i5_transaction(I5_ISOLEVEL_CHG);
if (!$ret)
{
print_r("i5_transaction error : ".i5_errormsg().'<br/>');
}
$sql = 'INSERT INTO RAPH.RBLOB VALUES(:pki ,:blobimg)';
$req_prepa = i5_prepare($sql,$Hdlcon);
if (is_bool($req_prepa))
{
print_r("i5_prepare error : ".i5_errormsg().'<br/>');
i5_rollback();
}
$ret0 = i5_setparam($req_prepa, "pki", 12 );
$URL = "http://www.easycomstore.com/Data/temp/11-Easycom-technology-a.jpg";
$file_image = fopen($URL, 'r');
$headers = get_headers('http://www.aura.com/Data/aura.jpg', true);
$file_size = $headers['Content-Length'];
$contents = fread($file_image, $file_size );
$ret2 = i5_setblob($req_prepa, "blobimg", $contents);
if ($ret2 === false)
{
print_r("i5_setblob error : ".i5_errormsg().'<br/>');
i5_rollback();
}
else
{
$ret = i5_execute($req_prepa);
if ($ret)
{
echo "Blob writing successful.<BR>";
$ret = i5_commit();
$reqtrans = i5_transaction(I5_ISOLEVEL_NONE,$Hdlcon);
}
else
{
print_r("i5_execute error : ".i5_errormsg().'<br/>');
i5_rollback();
}
}
See also