我有一个MySQL标准查询,我需要转换为Zend_Db_Select
但我无法让它工作。MySQL查询Zend DB选择
我得到这个错误:
Select query cannot join with another table
这里的查询:
// THE COUNTER
$subselect = $this->table->select()->from(
array('x' => 'blog_comments'),
array('x.post_id', new Zend_Db_Expr('count(*) as comments')))
->group('post_id');
// THE TOTAL SELECT
$select->from(array('p' => 'blog_posts'), array('p.*'))
->setIntegrityCheck(false)
->joinLeft(array(
'x' => $subselect,
'x.post_id = p.id',
array()
)
);
如果有人可以转换这一点,那将是伟大的,因为我需要在select()
模式,因为我用Zend_Pagination
。
对于那些想要完整的PHP函数:Pastebin和堆栈跟踪:Pastebin。
我得到一个'错误1064'。'SQLSTATE [42000]:语法错误或访问冲突:1064您的SQL语法错误;检查对应于你的MySQL服务器版本“为'x' ON x.post_id = p.id ORDER BY'created_date' DESC LIMIT 10”附近使用的线2' –