Zend DB 选择常量 - 表中不存在的列
我正在尝试使用 Zend DB select 执行此查询,但我无法这样做
这是 sql 查询
select shopping_id,shopping_details,"friend" as type from shopping
请注意这里我如何指定“friend”作为类型,而friend 不是购物表中的列。
现在我该如何在 Zend 中执行此操作。我已经尝试过这个,但它给了我一个错误,说“sh.friend 列不存在”
$select->from(array('sh'=>'shopping'),array('shopping_id','shopping_details','"friend" as type');
任何帮助将不胜感激 谢谢
I'm trying to do this query using Zend DB select but I'm not able to do so
This is the sql query
select shopping_id,shopping_details,"friend" as type from shopping
Notice here how I'm specifying "friend" as type and friend is not a column in the shopping table.
Now how do I do this in Zend. I have tried this but it gives me an error saying "sh.friend Column does not exist"
$select->from(array('sh'=>'shopping'),array('shopping_id','shopping_details','"friend" as type');
Any help will be appreciated
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试使用
Zend_Db_Expr
,也许类似:Try with
Zend_Db_Expr
, maybe something like:对于 Zend Framework 2/3 或 Laminas,您必须使用
Laminas\Db\Sql\Expression
。确保用双引号""
引用您的常量。*对于 Zend Framework,表达式类的名称是
Zend\Db\Sql\Expression
。For Zend Framework 2/3 or Laminas you have to use
Laminas\Db\Sql\Expression
. Make sure to quote your constant with a double-quote""
.*for Zend Framework the name of the expression class is
Zend\Db\Sql\Expression
.