-- David Rinaldi <[EMAIL PROTECTED]> wrote
(on Tuesday, 31 October 2006, 06:54 PM -0800):
> Using ZF 0.2.0 and PDO MySQL, I run into a peculiar case:
> 
> $sql = $db->quote('SELECT * FROM <table> ORDER BY date DESC LIMIT 10');

Your problem is with the above statement. quote() should be used to
quote scalar values to use *in* SQL statements, not the entire statement
itself; typically, you'll only use it to quote data you're selecting
against or pushing into an insert or update statement. 

In the example you have above, there's really no reason to do any
quoting.

Try 
    $sql = 'SELECT * FROM <table> ORDER BY date DESC LIMIT 10';

and use that with the rest of the code you have below.

> $result = $db->query($sql);
> $rows = $result->fetchAll();
> 
> returns 0 rows.
> 
> using the select object doing the same thing:
> 
> $select->from('<table>', '*');
> $select->order('date DESC');
> $select->limit(10);
> $rows= $db->fetchAll($select);
> 
> returns up to 10 rows...
> 
> These should be the same queries, so why the difference in return?

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to