Codeigniter Single and Multiple records Insert Query – onlinecode
In this post we will give you information about Codeigniter Single and Multiple records Insert Query – onlinecode. Hear we will give you detail about Codeigniter Single and Multiple records Insert Query – onlinecodeAnd how to use it also give you demo for it if it is necessary.
In this article, we will discuss about how to insert Single and Multiple records from the MySQL database using the CodeIgniter framework. if you want to insert single data into the database then we can use the Insert Query method and if you want to insert multiple records into the database then we can use the insert_batch Query Method.
so you can see the following two ways for Codeigniter insert database record.
Insert Single Record in CodeIgniter
In this step, we will insert a single row in CodeIgniter. so we will use the Insert Query method for the below example, You can see the following below example.
$data = array( 'title' => $this->input->post('txtTitle'), 'category' => $this->input->post('txtCategory'), 'description' => $this->input->post('txtDescription') ); $this->db->insert('product', $data);
Insert Multiple Records in CodeIgniter
In this step, we will insert multiple rows in CodeIgniter. so we will use the insert_batch Query method for the below example, You can see the following below example.
$data = array( array( 'title' => $this->input->post('txtTitle0'), 'category' => $this->input->post('txtCategory0'), 'description' => $this->input->post('txtDescription0') ), array( 'title' => $this->input->post('txtTitle1'), 'category' => $this->input->post('txtCategory1'), 'description' => $this->input->post('txtDescription1') ) }; $this->db->insert('product', $data);
Hope this code and post will helped you for implement Codeigniter Single and Multiple records Insert Query – onlinecode. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs