Zend_Db 查询 Mysqli 准备错误:操作数应包含 1 列
我的查询有问题,该查询在 phpmyadmin 中有效,但在 Zend_db 中无效。 您可以在具有多个连接的SQL语句中阅读有关查询的信息
我有这些表
Post
ID
entry
Category
ID
name
CategoryBinding
ID
postID
categoryID
还有这个是我的 php 代码:
class Blog_Model_DbTable_Posts extends Zend_Db_Table
{
protected $_name = 'Posts';
public function getByCategoryId($id)
{
$query =
"SELECT *
FROM `Post` AS `p`
LEFT JOIN `CategoryBinding` AS `cb` ON p.ID = cb.postID
LEFT JOIN `Category` AS `c` ON cb.categoryID = c.ID
INNER JOIN `Post` AS `p2` ON p.id = p2.id
WHERE p.id in
(
SELECT p2.id
FROM `Post` as `p2`
LEFT JOIN `CategoryBinding` AS `cb` ON p2.ID = cb.postID
LEFT JOIN `Category` AS `c` ON cb.categoryID = c.ID
WHERE c.id = 1
)
"
return parent::fetchAll($query);
我尝试使用 PDO 采用者 Boath 和 mysqli 采用者运行此查询。 我在 mysqli 采用者中遇到此错误。
Mysqli prepare error: Operand should contain 1 column(s)
我用谷歌搜索了一下,发现这可能是 Zend_Db 中的一个错误,但由于我的 sql 知识有些有限,我不知道我是否做错了什么,或者它是否确实是一个错误。 你能帮我解决这个问题吗? 保护你。
I have a problem with a query that works in phpmyadmin but not with Zend_db. You can read about the query in SQL statement with several joins
I have these tables
Post
ID
entry
Category
ID
name
CategoryBinding
ID
postID
categoryID
And this is my php code:
class Blog_Model_DbTable_Posts extends Zend_Db_Table
{
protected $_name = 'Posts';
public function getByCategoryId($id)
{
$query =
"SELECT *
FROM `Post` AS `p`
LEFT JOIN `CategoryBinding` AS `cb` ON p.ID = cb.postID
LEFT JOIN `Category` AS `c` ON cb.categoryID = c.ID
INNER JOIN `Post` AS `p2` ON p.id = p2.id
WHERE p.id in
(
SELECT p2.id
FROM `Post` as `p2`
LEFT JOIN `CategoryBinding` AS `cb` ON p2.ID = cb.postID
LEFT JOIN `Category` AS `c` ON cb.categoryID = c.ID
WHERE c.id = 1
)
"
return parent::fetchAll($query);
I have tried to run this query with boath the PDO adopter and with mysqli adopter. I get this error with the mysqli adopter.
Mysqli prepare error: Operand should contain 1 column(s)
I have googled about it and found that it maybe is a bug in Zend_Db, but since my sql knowledge is somewhat limited I do not know if I am doing something wrong or if it indeed is a bug. Can you please help me figuring this out?
Tank You.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
代替
使用
Instead of
Use