将带有子选择的 MySQL 查询转换为 Zend 格式
我想将此 MySQL 查询翻译为 Zend 格式:
SELECT count_panne, mvt, nextHost, dtmvt, stat
FROM ( SELECT COUNT(myTable.snMCB) AS count_panne,
myTable.mvt,
myTable.nextHost,
myTable.dtmvt,
myTable.stat
FROM myDB.myTable myTable
WHERE (myTable.dtmvt = calendar__gregorian__today__)
AND (myTable.statut = 'NOOK')
GROUP BY myTable.snMCB) AS myTempTable
WHERE count_panne > 2
ORDER BY count_panne DESC
(ps:这是带有修改的正确 mysql 句子)
我用 Zend 尝试了以下操作:
$subSelect = $dbTable->select()
->from($dbTable,array(
'COUNT(myTable.snMCB) AS count_panne',
'myTable.mvt',
'myTable.nextHost',
'myTable.dtmvt',
'myTable.nextHost'))
->where("myTable.dtmvt BETWEEN '$dateDeb' AND '$dateFin'")
->where('myTable.stat = ?', 'NOOK')
->group('myTable.snMCB')
;
$select = $dbTable->select()
->setIntegrityCheck(false)
->from(new Zend_Db_Expr($subSelect),
array('count_panne',
'mvt',
'nextHost',
'dtmvt',
'statut'))
->where('count_panne > 2')
->order('count_panne DESC')
;
它不起作用。
I would like to translate this MySQL query to the Zend format:
SELECT count_panne, mvt, nextHost, dtmvt, stat
FROM ( SELECT COUNT(myTable.snMCB) AS count_panne,
myTable.mvt,
myTable.nextHost,
myTable.dtmvt,
myTable.stat
FROM myDB.myTable myTable
WHERE (myTable.dtmvt = calendar__gregorian__today__)
AND (myTable.statut = 'NOOK')
GROUP BY myTable.snMCB) AS myTempTable
WHERE count_panne > 2
ORDER BY count_panne DESC
(ps: That's a correct mysql sentence with modifs)
I tried the following with Zend:
$subSelect = $dbTable->select()
->from($dbTable,array(
'COUNT(myTable.snMCB) AS count_panne',
'myTable.mvt',
'myTable.nextHost',
'myTable.dtmvt',
'myTable.nextHost'))
->where("myTable.dtmvt BETWEEN '$dateDeb' AND '$dateFin'")
->where('myTable.stat = ?', 'NOOK')
->group('myTable.snMCB')
;
$select = $dbTable->select()
->setIntegrityCheck(false)
->from(new Zend_Db_Expr($subSelect),
array('count_panne',
'mvt',
'nextHost',
'dtmvt',
'statut'))
->where('count_panne > 2')
->order('count_panne DESC')
;
It didn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过直接使用 db adpater 和 sql 来执行此操作,如...
Have you tried doing this using the db adpater direct with sql as in...