$sql = "select * from sometable where id = ?"
$data = 1;

FetchAll ($sql, $data)

Would replace the ? with the vaule of 1.

Actually that's not true - the signature for fetchAll in Zend_Db_Table uses an already-resolved string for the 'WHERE' clause.

If you want to utilise a number of placeholders from within a Zend_Db_Table you can approach it a number of ways, but here's two simple examples:-

Currently
$db = $this->getAdapter();
$where = array($db->quoteInto('id = ?', $id),
               $db->quoteInto('condition2 = ?', $foo),
               $db->quoteInto('condition2 = ?', $foo));
$rowSet = $this->fetchAll(join(' AND ', $where), $limit); // Assumes $limit is already set elsewhere

New Zend_Db_Table class in incubator
$select = $this->select()->where('id = ?', $id)
                         ->where('condition2 = ?', $foo)
                         ->where('condition3 = ?', $bar)
                         ->limit($limit);
$rowSet = $this->fetchAll($select);

Named placeholders are also being considered for the Zend_Db_Select component but not yet available.

Cheers


When we use Zend_DB_Table_Abstract fetchAll($where, $order) to get all the records from table. In the where clause, if we have several condition, for
example, condition1, condtion2, condition3. How do we put all these
conditions in the where clause? Thank in advance.

--

Simon Mundy | Director | PEPTOLAB

""" " "" """""" "" "" """"""" " "" """"" " """"" "  """""" "" "

PeptoLab will be closed:
Saturday 15th  December through until Monday 17th December
Saturday 22nd December through until Wednesday 2nd January
For urgent requests, please call 0438 046 061

202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124
http://www.peptolab.com

Reply via email to