I went with your second thought and came up with something like:
$ids = '1,2';
$tmpIds = explode( ',', $ids );
$tmpIds = array_map( array( $this->db, 'quote'), $tmpIds );
$cIds = implode( $tmpIds, ',' );
$sql = "SELECT * FROM cases WHERE enabled = 1 AND id IN ( " . $cIds . " )";
$dbRes = $this->db->query( $sql );
$res = $dbRes->fetchAll();
_____
From: David Rogers [mailto:[EMAIL PROTECTED]
Sent: Friday, April 04, 2008 11:14 AM
To: Mark Steudel
Subject: Re: [fw-general] Hiya - new - sql IN statements
Try sprintf() instead of quoteInto(), ie: sprintf("SELECT id FROM table
WHERE id IN ( %s )", $ids). It's not ideal, but it'll solve your problem.
You might also consider using an array for $ids and performing a callback on
the members ($db->quote()), then sticking the resultant values together with
implode().
On Apr 4, 2008, at 1:22 PM, Mark Steudel wrote:
Hi there,
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.
Thanks, Mark