php - 使用 Zend_Db_Expr

标签 php mysql zend-framework zend-db

我有以下查询:

$select = $this->getDao()->select()
                         ->from(
                           array(new Zend_Db_Expr('FROM_UNIXTIME(expiration)'))
                           );

getDao 函数是对我的数据访问对象类的引用,如下所示:

class Model_Db_AccountresetDao extends Zend_Db_Table_Abstract
{
    protected $_name = 'accountreset';
    protected $_primary = 'reset_id';
}

现在我得到以下错误:

"Select query cannot join with another table"

虽然我不想加入。我只想选择该字段作为 unixTimestamp

我该如何解决这个问题?

感谢所有帮助。

谢谢

最佳答案

如果你正在从 Zend_Db_Table_Abstract 中选择对象,你不能向他传递一个 ->from()。我认为你应该这样做

$select = $this->getDao()->select()  
                         ->from(this->getDao(),
                           array('_date or some field='.new Zend_Db_Expr('FROM_UNIXTIME(expiration)'))
                           );

或类似的东西。

关于php - 使用 Zend_Db_Expr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4325548/

相关文章:

javascript - 自动检测货币 PHP/Javascript

php - Laravel Blade 在幕后是如何工作的?

php - 更改 Zend_Framework 项目中的公用文件夹位置?

php - 使用 PHP end() 函数分配新 id

php - LessQL Like 运算符

php - 使用 MySQL INTO OUTFILE 不写入 tmp

javascript - 无法从另一个文件进行查询(connection.query 不是函数)

php - 多个站点运行共享 Zend Framework 的最佳方法?

php - 显示 Zend Framework 表中的所有记录

php - Zend 中的每个表都必须映射到它自己的类吗?