Re: Question about MDB2 portability of SELECT
| From: | Lorenzo Alberton | Date: | Thu, 13 Mar 2008 12:09:11 +0000 |
| Subject: | Re: Question about MDB2 portability of SELECT | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-28638@lists.php.net to get a copy of this message | ||
Dmitri wrote:
Chuck Burgess wrote:the WHERE ... IN (...) clause is portable. Just make sure you use $db->quote($value); for each value in the list, since there are quoting differences among the various DBMS. ======================================= $values = array('id2', 'id3', 'id4'); $quoted_values = array(); foreach ($values as $value) { //chose the right data type, in this example 'text' $quoted_values[] = $db->quote($value, 'text'); } $query = 'SELECT * FROM sometable WHERE message_id IN(' . implode(',', $quoted_values).')'; ======================================= HTH Best regards, -- Lorenzo Alberton http://pear.php.net/user/quipo ________________________________________________________________________ Quipo Free Internet: sicuro e veloce senza costi di attivazione e senza canone, 2 e-mail da 25 Mb, 150 Mb di spazio web e molto di più! Registrati gratis: http://www.quipo.itSELECT * from sometable where message_id IN('id2', 'id3', 'id4')Seems like the IN clause is ANSI standard, so I'm thinking it's safe to consider "portable". I've certainly used it in Oracle and Informix.