我想用idiorm&巴黎数据库工具包(http://j4mie.github.io/idiorormandparis/):
SELECT mqtt_table.* FROM `shelf_mqtt_confirmation_message` `mqtt_table` WHERE NOT( `confirm_result` <=> 'positive')
我试图做:
$orm->where_not_equal("confirm_result","positive");
,但这相当于:
SELECT mqtt_table.* FROM `shelf_mqtt_confirmation_message` `mqtt_table` WHERE NOT( `confirm_result` = 'positive')
不包括confirm_result
为null的所有情况:但是我也想保留这些行。问题是,在mysql =比较操作员中,如果要比较的元素之一为null而不是返回0,则返回null。null,如果一个操作数为null)
所以我的问题是,iDiorm&amp;巴黎?除了使用RAW_QUERY或WHERE_RAW的残酷方法吗?
可以使用 where_raw()
docs link method。
可以重写以下SQL查询
SELECT *
FROM shelf_mqtt_confirmation_message
WHERE NOT(confirm_result <=> 'positive')
在以下代码中使用idiorm
$messages = ORM::for_table('shelf_mqtt_confirmation_message')
->where_raw('NOT(confirm_result <=> ?)', array('positive'))
->find_many();
在巴黎 docs link 它可能是
$messages = ShelfMqttConfMessage::where_raw(
'NOT(confirm_result <=> ?)', array('positive')
)
->find_many();
或者您正在使用模型工厂
$messages = Model::factory('ShelfMqttConfMessage')
->where_raw('NOT(confirm_result <=> ?)', array('positive'))
->find_many();