MongoDb-ORM操作,依赖\x\MongoDb
组件实现。
whereNotIn()
主要用于实现查询条件中的Not In
不包含查询语句构造。
例如:
$Mongo = new \x\MongoDb();
$Mongo->table('user')->name('log')->where('id' , 1)->whereNotIn('pid', '1,2,3,4');
最终生成的命令结果:
{
"id": 1,
"pid": {
"$nin": [
"1",
"2",
"3",
"4"
]
}
}
也支持传入数组的方式:
$inArray = [
1,
2,
3,
4,
];
$Mongo = new \x\MongoDb();
$Mongo->table('user')->name('log')->where('id' , 1)->whereNotIn('pid', $inArray);
最终生成的命令结果:
{
"id": 1,
"pid": {
"$nin": [
1,
2,
3,
4
]
}
}
注意:whereNotIn()
方法中,使用数组或者字符串传入的方式,对最终生成in命令的数据类型是有区别的。