RE: [PHP] Array vs. Scalar Lists
| From: | Lars Torben Wilson | Date: | Sat, 02 Dec 2000 05:02:29 +0000 |
| Subject: | RE: [PHP] Array vs. Scalar Lists | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28289@lists.php.net to get a copy of this message | ||
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|
+----------------------------------------------------------------+