<?php

/**
 * Created by PhpStorm.
 * User: joe
 * Date: 17-1-23
 * Time: 下午2:33
 */
class Page_model extends CI_Model {

    public function __construct() {
        $this->load->database();
    }

    public function get($id=null,$select=null,$where=null,$join=null) {
        if ($select) $this->db->select($select);
        if ($where) $this->db->where($where);
        if ($join) {
            $this->db->join('users','users.id=page.user','left')
                ->join('category','category.id=page.category','left');
        }

        if ($id) {
            return $this->db->get_where('page',['page.id'=>$id])->row_array();
        }

        return $this->db->get('page')->result_array();
    }
}