public function testKeyFilter()
 {
     $model = new MockModel($this->db);
     $model->add_include("many", ["table" => "jointable"]);
     foreach ($model->getManyIncludes() as $options) {
         $query = new IncludeManyQuery($this->db, $options, [1]);
         $query->build();
         $this->assertEquals($query->query->getSQL(), "SELECT l.id as lkey, r.* FROM example l LEFT JOIN example_jointable j ON j.example_id = l.id LEFT JOIN jointable r ON r.id = j.jointable_id WHERE (r.id IS NOT NULL) AND (l.id IN (1))");
     }
 }
Beispiel #2
0
 private function include_many($options)
 {
     $model_indices = [];
     foreach ($this->model->result as $res) {
         $model_indices[] = $res[$options["key"]];
     }
     $query = new IncludeManyQuery($this->model->db, $options, $model_indices);
     $joins = $query->execute();
     $this->fill_data($joins, $options);
 }