N
N
Ninazu2016-05-27 11:53:48
Yii
Ninazu, 2016-05-27 11:53:48

How to select records from MongoDB in Yii2?

Actually, I understand how to select records in monge

db.getCollection('params').find({params: {$elemMatch : {scheduler_settings:{$ne:[]}}}})

And how to implement it through Yii2 component?
Tried these options. But it didn't work.
Params::find()->where([
  'params' => [
    '$elemMatch' => [
      'scheduler_settings' => '{$ne:[]}'
    ]
  ]
])->all();

Params::findAll('{params: {$elemMatch : {scheduler_settings:{$exists:true}}}}');

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
VitGun, 2016-05-27
@VitGun

in pure PHP something like this

$data = $_POST["data"];
    $conn = new MongoClient();
    $db = $conn->ETM;
    $collection = $db->ETM;    
    $cursor = $collection->find(['DEALDATE'=>$data]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question