CodeIgniter Forums
Migration 2 -> 4 : database - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Migration 2 -> 4 : database (/showthread.php?tid=75903)



Migration 2 -> 4 : database - lama - 03-28-2020

Hello,

I'm looking for a migration of CI2 to CI4... Well i know ... Angel

Is there a simple way to keep the database queries "as is" from CI2 in CI4 ?

For example, what I wrote in my CI2 application :
PHP Code:
$this->db->select('products.products_id, products_name, products_uri, products_ean, products_image_type, products_price, products_stock_quantity');
$this->db->from('products');
$this->db->join('products_stock''products.products_id = products_stock.products_id');
$this->db->where('products_is_displayed'1);
$this->db->where('products_image_type !=''none');
$this->db->order_by('products_time_add''desc');
$this->db->limit($limit);
$query $this->db->get();
return 
$query->result_array(); 


I want to rewrite less as possible because if an application with a huge amount of database manipulation .. Confused

Thanks


RE: Migration 2 -> 4 : database - MGatner - 03-30-2020

There is not an easy way to do this. If you have such a large amount you may be able to write your own class and load the database builder into its $db property, but some of the methods have changed so it would still involve some manipulation.