1

I have two tables USERS and join_class, according to MCV each table has its own Model which means i have two models ... USER MODEL and JOIN_CLASS MODEL. How can i use two model in a single view.

JOIN_CLASS TABLE
id  user_id  class_id   
2   19        3
3   19        24
15  19        80
16  19        60

USERS TABLE
id firstname    lastname        
1   Sizwe       Funeka 
10  King        Ngcobo  
11  Sabza       Jingose     

How can i create something like this....

    $query = "select * from ".$this->table." where ";
    foreach ($keys as $key) {
        $query .= $key . "=:" . $key . " && ";
    }
    $query = trim($query,"&& ");
    $query .= " order by id "  

Instead of this...

  SELECT u.id, u.first_name, u.last_name
        FROM users u, join_class j
        WHERE j.user_id = u.id
        AND j.class_id = 60

using MCV Model.

i want to join this two model and also create JOIN clause

Sizwe
  • 11
  • 1

0 Answers0