Zend_Db 来自 SQL 字符串的占位符问题
我有以下 SQL
SELECT i_id AS "entity_id", "entity_1" AS "type"
FROM tbl_extensions WHERE ext = 50
,它返回结果和一个附加列“type”,其值为“entity_1”,
以获得与我尝试过的 Zend_Db 相同的结果:
$db->fetchAll($db->select()
->from('tbl_extensions',
array('entity_id' => 'i_id',
'type' => 'entity_1'))
->where('ext = ?', 50)));
但我有以下错误:
消息:SQLSTATE[42S22]:未找到列:1054“字段列表”中的未知列“tbl_extensions.type”
看起来 Zend 尝试查找列而不是在结果中创建它。
有人可以帮我吗?
I have the following SQL
SELECT i_id AS "entity_id", "entity_1" AS "type"
FROM tbl_extensions WHERE ext = 50
which returns me the result and an additional column "type" with the value "entity_1"
to gain the same with Zend_Db I've tried:
$db->fetchAll($db->select()
->from('tbl_extensions',
array('entity_id' => 'i_id',
'type' => 'entity_1'))
->where('ext = ?', 50)));
But I have the following error:
Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tbl_extensions.type' in 'field list'
It looks like Zend tries to find a column instead of creating it within the result.
Could anyone help me with it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的解决方案是使用
Zend_Db_Expr
。easiest solution would be to use
Zend_Db_Expr
.