I am implementing my model exactly like the quickstart guide.
In my model I am trying to implement a findByToken()
method. The current find()
method accepts an $id
parameter, but I want to find by the value of a different column.
//excerpt from the quickstart guide
public function find($id, Default_Model_Guestbook $guestbook)
{
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
return;
}
$row = $result->current();
$guestbook->setId($row->id)
->setEmail($row->email)
->setComment($row->comment)
->setCreated($row->created);
}
I tried doing something like this, but I don't think it worked:
$db = $this->getDbTable();
$where = $db->getAdapter()->quoteInto('token = ?', $token);
$result = $db->find($where);
What would be the proper way to find a row by the value of a specified column?