I have a query to move the contents from one table to another using native php
, after I use Codeigniter
I am confused to use Query Builder Class which is most suitable for my needs:
$this->db->query('INSERT INTO t_pr (ID_PR,no_pr,dept,pr_date,pr_create_date,product_name,qty,uom,Remarks,status_line,status_pr,data_entry)
SELECT ID_PR,no_pr,dept,pr_date,pr_create_date,product_name,qty,uom,Remarks,status_line,status_pr,data_entry FROM t_pr_temp');
You can't. The ActiveRecord and QueryBuilder does not support INSERT...SELECT
functionality.
With plain SQL you always can do more than via any abstraction layer (e.g. ORM, ActiveRecord, QueryBuilder, etc.), because different DB servers have different native functionalities.
Using Codeigniter QueryBuilder You might want to use it like this:
$this->db->insert_batch( 't_pr ', $this->db->get('t_pr_temp') );