Zend Framework: How to find a table row by the value of a specified column?

让人想犯罪 __ 提交于 2019-12-05 16:03:47
$result = $db->fetchAll($where);

or if you are trying to retrieve only one row.

$result = $db->fetchRow($where);

You could also use the Zend_Db_Select Object, keeping the adapter a little further abstracted:

$db = $this->getDbTable();
$select = $db->select()->where('token = ?', $token);
$result = $db->fetchAll($select);

This can be easily done by creating select object and fetching a row using this object. It's well described in manual: http://framework.zend.com/manual/en/zend.db.select.html#zend.db.select.execute

Your code could look like:

$select = $this->getDbTable()->select()->where('token = ?', (string) $token);
$row = $this->getDbTable()->fetchRow($select);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!