<?php class Model_insert extends CI_Model{ public function __construct(){ parent::__construct(); $this->load->database(); } function insert_data(){ $value=array( 'name'=>'山田', 'gender'=>'女', 'birthday'=>'2001-07-09', ); $sql =$this->db->insert('profile',$value); $this->db->query($sql); } } ?
<?php class Database2 extends CI_controller{ function index(){ $this->load->model('model_insert'); $this->model_insert->insert_data(); } } ?
モデルにDBの処理を全部書いてしまうのはまずいでしょうか。どう変えればいいでしょうか。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/03/10 05:01
2017/03/10 05:12