This one is for me, since I seem to forget Magento’s query binding syntax every time I stay away from it fore more than a week.
$sql = "select foo
from bar
where baz = ?";
$query = Mage::getSingleton('core/resource')->getConnection('core_read')
->query($sql,array($value));
while($row = $query->fetch())
{
var_dump($row);
}
The biggest gotcha is not put your bind params (?) in quotation marks
where baz = '?' ";
The confusing the parsing engine, and makes it think there aren’t the right number of tokens. There’s also a named paramater syntax, which my old man tendencies avoids.