非常简单的 Zend_Db_Table 问题
我知道这听起来非常简单,但在谷歌上根本找不到关于这个主题的文档。
我想从数据库中选择两列。我创建了一个 Zend_Db_Table 对象并将其指向我的表。
现在我想选择两列:customerId 和 name。
我应该怎么做才能只选择这两列而不是整个表?
提前致谢,我会给你烤蛋糕或者打扫你的房间。
I know this sounds rediculously easy but there is simply no documentation about this subject findable on google.
I'd like to to select two columns from the database. I made a Zend_Db_Table object and point it to my table.
Now I like to select two columns: customerId and name.
What should I do to select just those two columns and not the whole table?
Thanks in advance, I'll bake you a cake or clean your room.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
谢谢,我已经有女佣了;)
And thanks, I already have a maid ;)
您必须将所需的字段作为第二个参数传递给 from() 方法,第一个参数是表。
我知道这有点令人困惑,因为在常规 sql 语法中,所需的字段首先出现,但如果您想以模块化方式构建查询,zend db 会非常方便。
接受字符串数组和单个字符串
另一个例子:
you have to pass the desired fiels as the second argument to the from() method, the first is the table.
i know its a bit confusing because in regular sql syntax the desired fields go first, but zend db comes in quite handy if you want to custruct queries a modular way.
array of strings and single string is accepted
another example: