Apr 20 at 9:55am, Alex Hogan wrote:
> function myselect($array1, $array2){
> $query = "SELECT".foreach($array1 as $flds){ $flds[$i]; }.
>     "FROM".foreach($array2 as $tbls){ $tbls[$n]; } ...

Alex, if you merely wish to place the values of an array into your 
query, you might also try doing it this way:

$query = 'SELECT '. implode(', ', $array1).
    ' FROM '. implode(', ', $array2). ' ... ';

Usually when writing queries, I prefer to use sprintf():

$q = 'SELECT %s FROM %s';
$q = sprintf($q, implode(', ',$array1), implode(', ',$array2));

The more complex the query gets, the easier it is to read using this 
approach. I'm sure some find that debatable. After all, I'm crazy ;)

--
Kelly Hallman

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to