Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Comments_model extends CI_Model {
- function get_comments ($article_id){
- $this->db->select('*');
- $this->db->from('users');
- $this->db->join('articles', 'users.user_id = articles.user_id');
- $query = $this->db->get();
- // Produces:
- // SELECT * FROM users
- // JOIN users ON users.user_id = articles.user_id
- foreach ($query->result() as $row)
- {
- echo $row->user_id;
- echo $row->article_id;
- echo $row->article_name;
- }
- if($var == NULL){
- return NULL;
- }
- return $var;
- }
- }
Add Comment
Please, Sign In to add comment