RE: [PHP] Array vs. Scalar Lists
| From: | Anthony Martin | Date: | Fri, 01 Dec 2000 21:03:05 +0000 |
| Subject: | RE: [PHP] Array vs. Scalar Lists | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-28290@lists.php.net to get a copy of this message | ||
It's more like a feature request for all of PHP, not just ibase_execute().
A passed array should look exactly like a list of scalars...it does in perl
anyway. Oh well.
Anthony
-----Original Message-----
From: Lars Torben Wilson [mailto:torben@php.net]
Sent: Friday, December 01, 2000 9:02 PM
To: Anthony Martin
Cc: 'php-general@lists.php.net'
Subject: RE: [PHP] Array vs. Scalar Lists
Anthony Martin writes:
> Ok, like I said, I'm using echo as an example. What I'm really trying to
do
> is a little more complicated:
>
> $data = Array ( 'c1f2g3h4j5r', 'AC', ) ;
> $stmt = 'SELECT * FROM PROFILE WHERE SESSION = ? AND STATUS = ? ;' ;
> $prep = ibase_prepare ( $dbh, $stmt ) ;
> $result = ibase_execute ( $prep, $data[0], $data[1] ) ;
>
> I want to avoid having to pass each value of the array to ibase_execute.
I
> would much rather do:
>
> $result = ibase_execute( $prep, $data ) ;
>
> But this function wants to see two values. It doesn't take into account
> that it's been given an array with two values in it. So if I want a
> programmatic solution, I have to use my eval() insanity (or is that evil
> insanity like Microsoft's spell check keeps telling me it is).
>
>
> Anthony
If you know the layout of the query at coding time (i.e. you're not
building $stmt at runtime) you can just modify the example in the
manual: http://www.php.net/manual/function.ibase-execute.php
<?php
error_reporting(E_ALL);
$data = array('c1f2g3h4j5r', 'AC');
$stmt = 'SELECT * FROM PROFILE WHERE SESSION = ? AND STATUS = ? ;';
list($session, $ac) = $data;
$prep = ibase_prepare($dbh, $stmt);
$result = ibase_execute($prep, $session, $ac);
?>
Looking at ibase_execute(), though, it seems like in order to be
really useful it should accept either a list of ints or an
array...that would make a good feature request.
--
+----------------------------------------------------------------+
|Torben Wilson <torben@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+