Guest User

Untitled

a guest
Jun 25th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. class Bruger_model extends CI_Model
  2. {
  3.  
  4.     function __construct()
  5.     {
  6.         $this->load->database();
  7.         parent::__construct();
  8.     }
  9.    
  10.     public function get_topics()
  11.     {
  12.       $query = $this->db->select('topics.name AS topic_name, quotes.name AS quote_name')
  13.                 ->from('quotes')
  14.                 ->join('topics', 'quotes.topic_id = topics.id')
  15.                  ->where('quotes.user_id', '1')
  16.               ->order_by('topics.name', 'ASC');
  17.  
  18.       $topics = array();
  19.       foreach ($query->result() as $row)
  20.       {
  21.         $topics[$row->topic_name][] = $row->quote_name;
  22.       }
  23.       return $topics;
  24.     }
  25.  
  26. }
  27.  
  28. /* End of file Class_name.php */
  29. /* Location: ./application/models/Class_name.php */
Add Comment
Please, Sign In to add comment