<?php class models_id extends CI_Model{ public function __construct(){ parent::__construct(); $this->load->database(); } function insert_data($value){ $this->db->insert('profile',$value); $id=$this->db->insert_id(); echo "$id"; $this->output->enable_profiler(TRUE); } } ?>
<?php class Controllers_id extends CI_controller{ function index(){ $value=array( 'name'=>'田中', 'gender'=>'女', 'birthday'=>'2001-07-09', 'address'=>'仙台', ); $this->load->model('models_id'); $this->models_id->insert_data($value); } } ?>
$id=$this->db->insert_id();の部分です。
insert_idを使わない別の方法で挿入したidを取得する方法ってありますか?
回答2件
あなたの回答
tips
プレビュー