<?php

/**
 * Created by PhpStorm.
 * User: joe
 * Date: 16-9-6
 * Time: 下午4:11
 */
class Question_model extends CI_Model {

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

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

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

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