あなたは、MY_Modelを作成するには、このようなものでした:あなたは、その後のメソッドを使用することができます
class My_Table_model extends MY_Model {
function __construct(){
parent::__construct();
$this->table='my_table';
}
}
:
class MY_Model extends CI_Model {
var $table = '';//database table
function __construct(){
parent::__construct();
}
public function get($id = NULL) {
$query = $this->db->get_where($this->table, array('id' => (int)$id), 1, 0);
if ($query->num_rows() === 1) {
return = $query->result();
}
return NULL;
}
function get_one($id=NUNLL){}
function update($id=NULL, $data=array()){}
function delete($id=NULL){}
etc...
}
そしてテーブルあたりのモデルにあなたがMY_Modelを拡張することができ、このような何かあなたのモデルのMy_Modelから。あなたが何かを上書きしたい場合は
class Table_Controller extends Front_Controller {
function __construct(){
parent::__construct();
$this->load->model('my_table_model');
}
function comments(){
$this->my_table_model->get($get_id_somehow);
}
}
は、あなたのモデルでこのようにそれを行うことができますMy_Modelが伸びる:
function my_method($id=NULL, $data=array()){
return parent::my_method($id, $data);
}
*(公式)* [作成あなたのコントローラで あなたはこのようなものを持つことができます20分でブログ](http://codeigniter.com/tutorials/watch/blog/) – Gordon