Guest User

Untitled

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