I have the following:
public function getAll($limit = 100)
{
//if ($thread != 0) { $threadq = "WHERE threadId=$threadId"; }
$query = <<<EOF
SELECT
x.*
FROM x
ORDER BY dater DESC
LIMIT ?
EOF;
return self::$db->fetchAll($query, $limit);
}
It seems it turns the LIMIT x into LIMIT 'x' and so the MySQL query parser goes wrong and complains.
However doing LIMIT $limit works fine
Why does this not work? and is there another method of doing this?
I’m going to go crazy and suggest you keep it easy and use Zend_Db_Select. This appears to be a simple query.
This demonstration uses a default ZF DbTable as the the adapter (I could just as easily use
Zend_Db_Table::getDefaultAdapter();), however it can be adapted to almost any type of query: