Using Zend_Db_Expr

I have the following query:

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

The getDao function is a reference to my Data Access object class, which looks like this:

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

Now I get the following error:

"Query selection cannot connect to another table"

This is while I do not want to make a connection. I just want to select this field as unixTimestamp

How can I solve this problem?

All help is appreciated.

Tpx

+3
source share
1 answer

If you selected a select object from Zend_Db_Table_Abstract, you cannot pass it to it ->from(). I think you should do it

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

or something like that.

+2
source

Source: https://habr.com/ru/post/1777929/


All Articles