我正在使用 Zend Framework 1.x 版
refresh
方法的文档Zend_Db_Table_Row_Abstract
只说:
Refreshes properties from the database.
我的问题是,如果同时从数据库中删除了该行(即通过其他进程),此方法将返回什么?
它是否能够通过返回 null 或抛出异常来处理这种情况?
谢谢,雅各布
我正在使用 Zend Framework 1.x 版
refresh
方法的文档Zend_Db_Table_Row_Abstract
只说:
Refreshes properties from the database.
我的问题是,如果同时从数据库中删除了该行(即通过其他进程),此方法将返回什么?
它是否能够通过返回 null 或抛出异常来处理这种情况?
谢谢,雅各布
首先resfresh()
只是调用_refresh()
,如果$row === null
返回一个Exception
.
protected function _refresh()
{
$where = $this->_getWhereQuery();
$row = $this->_getTable()->fetchRow($where);
if (null === $row) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception('Cannot refresh row as parent is missing');
}
$this->_data = $row->toArray();
$this->_cleanData = $this->_data;
$this->_modifiedFields = array();
}