Subject Re: [firebird-php] Paramter Queries
Author Robert martin
Hi

Just checked and I was wrong. The code does work ok with binary / blob
data !


Rob







Robert martin wrote:
>
>
> Hi
>
> I am a PHP newbie.
>
> I was using PDO for other Dbs but have switched to using the
> firebird/interbase drivers as the PDO firebird stuff was full of bugs.
>
> Anyway I have got my php connecting, disconnecting and using
> transactions ok. However I am struggling with running queries that take
> parameters. In the PDO drivers I used a bindparam function to assign a
> value to a named parameter. However I cant see an equivelent function
> for the native drivers. I see that ibase_execute and ibase_Query take a
> 'bind_arg' list of parameters that fill in '?' indicated parameters.
>
> First Question
> I would like to do queries like "Update TableName SET Field1 =
> :Field1Param WHERE Field2 = :Field2param" and assing parameters by
> name. IS this at all possible ?
>
> If I do have to use "Update TableName SET Field1 = ? WHERE Field2 = ?" I
> have found the following function (which I don't fully understand) that
> takes an array of params and runs an execute. I am using it and it
> appears to work well.
>
> function db_execute($stmt, $data)
> {
> if(!is_array($data))
> return ibase_execute($stmt,$data);
>
> $params = array();
> while( list($k,$v) = each($data) )
> $params[$k] = '$data['.$k.']';
> eval('$rc=ibase_execute($stmt,'.join(',',$params).');');
>
> return $rc;
> }
>
> If I am using the above and I want to pass in Blob (binary) data as 1 or
> more of the params I suspect the above will fail, correct?
>
> If so what should I do?
>
> Sorry about the long email :)
>
> Thanks
>
> Rob
>
>