i5_setblob

 

Writes binary data's in a BLOB type field.

 

bool i5_setblob (

resource result,
int position, string blob )

 

Details

 

Writes a characters 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.

 

Parameters

 

stmt

Parameterized request ID

position

Parameter index

blob

Binary chain content

 

Returns:

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.

 

 

Example

 

 

$ret = i5_transaction(I5_ISOLEVEL_CHG);

if (!$ret) trigger_error("i5_transaction error : ".i5_errormsg(), E_USER_ERROR);

 

/* Writing jpeg file content in blob */

$sql = "INSERT INTO easycom/s_employee (LASTNAME, FIRSTNAME, PHOTO, EMPNO, PHONEEXT, HIREDATE, SALARY) VALUES (?,?,?, 999, '+033', '1974-04-14', 1000)";

$req_prepa = i5_prepare($sql);

if (is_bool($req_prepa))

trigger_error("i5_prepare error : ".i5_errormsg(), E_USER_ERROR);

 

$name = "DUPONT";

$prenom = "HENRY";

 

$URL = realpath("./")."\inconnu.jpg";

$file_image = fopen($URL, 'r');

$contents = fread($file_image, filesize($URL));

 

$ret0 = i5_setparam($req_prepa, 0, $name);

if (!$ret0) trigger_error("i5_setparam error : ".i5_errormsg(), E_USER_ERROR);

  

$ret1 = i5_setparam($req_prepa, 1, $prenom);

if (!$ret1) trigger_error("i5_setparam error : ".i5_errormsg(), E_USER_ERROR);

  

$ret2 = i5_setblob($req_prepa, 2, $contents);

if (!$ret2) trigger_error("i5_setblob error : ".i5_errormsg(), E_USER_ERROR);

 

$ret = i5_execute($req_prepa);

if ($ret)

echo "Blob writing successful.<BR>";

else

trigger_error("i5_execute error : ".i5_errormsg(), E_USER_ERROR);

 

$ret = i5_commit();

if (!$ret) trigger_error("i5_commit error : ".i5_errormsg(), E_USER_ERROR);

 

 

See also

 

i5_setparam

i5_getblob