zend framework 查询遇到点小疑点,多谢大神们

WBOY
Release: 2016-06-13 12:04:14
Original
853 people have browsed it

zend framework 查询遇到点小问题,谢谢大神们
$tableUsers_1 = Engine_Api::_()->getDbtable('users', 'user');
$select_companies = $tableUsers_1->select();
$select_companies->where('`'.$table->info('name').'`.`level_id` = ?', 6);  

这样是查询满足level_id=6的条件是吧,那么我想查询既满足level_id=6又满足enabled=1,查询语句该怎么写呢,这两个条件都在这一个表中。还有  where('`'.$table   中的 '`' 是什么意思! 
------解决方案--------------------
$select_companies->where('`'.$table->info('name').'`.`level_id` = ? and `enabled `=1', 6);  

where('`'.$table   中的 '`' 是字符串拼接,`是用來轉義表名,字段名的,因為如果你表名是index(index 是sql關鍵字),直接寫select * from index 會錯,需要寫成 select * from `index`

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!