Guest User

Untitled

a guest
Jun 23rd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. <?php
  2.  
  3. class Comments_model extends CI_Model {
  4.    
  5.     function get_comments ($article_id){
  6.                                  
  7.         $this->db->select('*');
  8. $this->db->from('users');
  9. $this->db->join('articles', 'users.user_id = articles.user_id');
  10.  
  11. $query = $this->db->get();
  12.  
  13. // Produces:
  14. // SELECT * FROM users
  15. // JOIN users ON users.user_id = articles.user_id
  16.        
  17.         foreach ($query->result() as $row)
  18. {
  19.    echo $row->user_id;
  20.    echo $row->article_id;
  21. echo $row->article_name;
  22.  
  23. }
  24.        
  25.         if($var == NULL){
  26.             return NULL;
  27.         }
  28.        
  29.  
  30.         return $var;
  31.        
  32.     }
  33.    
  34. }
Add Comment
Please, Sign In to add comment