Zend DB 选择常量 - 表中不存在的列 [英] Zend DB Selecting constants - columns that do not exist in table

查看:33
本文介绍了Zend DB 选择常量 - 表中不存在的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Zend DB select 执行此查询,但我无法这样做

这是sql查询

<前>选择shopping_id,shopping_details,"friend" 作为类型从购物

注意这里我是如何指定朋友"作为类型的,而朋友不是购物表中的一列.

现在我如何在 Zend 中执行此操作.我试过这个,但它给了我一个错误,说sh.friend Column不存在"

<前>$select->from(array('sh'=>'shopping'),array('shopping_id','shopping_details','"friend" as type');

任何帮助将不胜感激谢谢

解决方案

尝试使用 Zend_Db_Expr,可能类似于:

$select->from(array('sh'=>'shopping'),数组('shopping_id','shopping_details',new Zend_Db_Expr('"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

解决方案

Try with Zend_Db_Expr, maybe something like:

$select->from(array('sh'=>'shopping'),
    array('shopping_id','shopping_details',
         new Zend_Db_Expr('"friend" as type'));

这篇关于Zend DB 选择常量 - 表中不存在的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆