Ahhh I like that much better ... Thanks!
-----Original Message-----
From: Matthew Weier O'Phinney [mailto:[EMAIL PROTECTED]
Sent: Friday, April 04, 2008 10:36 AM
To: [email protected]
Subject: Re: [fw-general] Hiya - new - sql IN statements
-- Mark Steudel <[EMAIL PROTECTED]> wrote
(on Friday, 04 April 2008, 10:22 AM -0700):
> New to the list and to Zend. I've primarily been using PEAR packages in
the
> past, but am switching to Zend. I love the fact that it's a glue stack
versus
> full stack and I can just implement classes as needed before jumping all
in.
>
> Anyway my first question is:
>
> What is the best way to run this sql statement
>
> $sql = "SELECT id FROM table WHERE id IN ( ? )"';
>
> I tried doing:
>
> $ids = '1,2';
>
> $res = $db->quoteInto( $sql, $ids );
>
> or
>
> $res = $db->fetchAll( $sql, $ids );
>
> But instead I get my sql statement returned to me.
I'd recommend instead using Zend_Db_Select to build your query:
$ids = array(1, 2);
$select = $db->select()
->from('table', array('id'))
->where('id IN (?)', $ids);
$res = $db->fetchAll($select);
Zend_Db_Select is a great tool for programmatically building queries
with ZF and ensuring that quoting occurs appropriately.
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/