ZF2 Inner加入其他时间戳

时间:2017-02-20 14:57:23

标签: php mysql zend-framework zend-framework2

ZF2内部加入其他时间戳

大家好,我想用Zend Framework 2(ZF2)检测da数据库中的优势边缘。 在mySQL中,它可以使用此命令:

SELECT Ta1.datetime, Ta1.SensorId_47, Ta0.SensorId_47
FROM data_newobjects Ta1
INNER JOIN data_newobjects Ta0
ON Ta1.datetime  = Ta0.datetime + SECOND(10)
WHERE (Ta1.SensorId_47 LIKE "1%" AND Ta0.SensorId_47 LIKE "0%");

但是我怎样才能加入下一个时间戳,例如" + SECOND(10)"在ZF2?

如果我在ZF2中加入相同的时间戳,它可以工作:

$sm = $this->getServiceLocator();
$sql =new Sql($sm->get('adapter_rohdata'));

$exp_Text = "`Ta_1`.`datetime` AS `summe`";
$select = $sql->select();
$select->columns(array(new Expression($exp_Text))); 
$select->from(array('Ta_1' => 'data_newObjects'));      
$select->join(array('Ta_0' => 'data_newObjects'), 'Ta_1.datetime=Ta_0.datetime', array(), \Zend\Db\Sql\Select::JOIN_INNER);
$select->where->like('Ta_0.SensorId_47', "0%");     
$select->where->like('Ta_1.SensorId_47', "1%");     

$statement = $sql->prepareStatementForSqlObject($select);   
$results = $statement->execute();   

但我没有找到解决方案,因为" next"时间戳,就像在mySQL中工作一样,例如"Ta1.datetime = Ta0.datetime + SECOND(10)"

感谢您的帮助......我真的寻求帮助,并尝试了很多......

1 个答案:

答案 0 :(得分:0)

获得解决方案from this post

$select->join(
    array('Ta_0' => 'data_newObjects'), 
    new \Zend\Db\Sql\Expression('Ta_1.datetime = Ta_0.datetime + SECOND(10)'),
    array()
);