Home >Backend Development >PHP Tutorial >zend framework 查询遇到点小问题,谢谢大神们

zend framework 查询遇到点小问题,谢谢大神们

WBOY
WBOYOriginal
2016-06-23 13:52:12794browse

$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`

$select_companies->where('`'.$table->info('name').'`.`level_id` = ? and `enabled `=1', 6);  

where('`'.$table   中的 '`' 是字符串拼接,`是用???表名,字段名的,因?如果你表名是index(index 是sql??字),直接?select * from index ??,需要?成 select * from `index`



恩 恩 好的 谢谢!!!
Statement:
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