zend-framework - 发送 : How to use 'not equal to' in WHERE clause?

标签 zend-framework mysql where-clause

我正在使用以下 zend 代码从 verified=1 的表中选择所有数据,它对我有用。

$table = $this->getDbTable();
$select = $table->select();
$select->where('verified = 1');
$rows = $table->fetchAll($select);

不,我想从该表中选择所有已验证不等于“1”的数据。我尝试了以下方法,但它没有获取数据。

$select->where('verified != 1');
$select->where('verified <> 1');
$select->where('verified != ?', 1);

“已验证”列的数据结构:

Field: verified
type: varchar(45)
Collation: utf8_bin         
NULL: Yes   
Default: NULL  

知道如何在 Zend 的 WHERE 子句中使用“不等于”运算符吗?谢谢

最佳答案

$select->where('verified != ?', 1);

现实世界的查询示例:

    $query = $this->getDb()->select();
    $query->from('title', array('title_id' => 'id', 'title', 'production_year', 'phonetic_code'))
            ->where('kind_id = 1')
            ->where('title = ?', trim($title))
            ->where('production_year != ?', '2009')
            ->limit(1)
            ;

从 IMDB 数据库中选择电影信息。工作正常。

关于zend-framework - 发送 : How to use 'not equal to' in WHERE clause?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1932431/

相关文章:

MySQL连接水平与垂直表

mysql - 在SQL中的几个值中查找多个值

zend-framework - 是否可以为 zend 模型使用多个命名空间以及如何自动加载它?

zend-framework - Zend Framework : How and where to create custom routes in a 1. 8+ 应用程序?

php - 未找到类 'Zend_Form_Subform'

mysql - 设计一个数据库来处理产品变化的库存跟踪

php - Zend 错误字符串

java - 在 JDBC 中转义单引号(出现错误 : You have an error in your SQL syntax . ..)

sql - 如何在where条件SQL中插入if

mysql - 如何将值从文件加载到mysql,在(文件)中