CodeIgniter Forums
CI4 what to use instead of db_select - 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: CI4 what to use instead of db_select (/showthread.php?tid=81483)



CI4 what to use instead of db_select - serialkiller - 03-09-2022

With CI3 when I needed to change the database name and not the connection I could use:

PHP Code:
$this->db->db_select('DB_NAME'); 


How can I do the same thing in CI4?


RE: CI4 what to use instead of db_select - kenjis - 03-09-2022

$db->setDatabase($database2_name);
https://codeigniter4.github.io/userguide/database/connecting.html?highlight=setdatabase


RE: CI4 what to use instead of db_select - serialkiller - 03-09-2022

(03-09-2022, 03:04 AM)kenjis Wrote: $db->setDatabase($database2_name);
https://codeigniter4.github.io/userguide/database/connecting.html?highlight=setdatabase

Perfect, I missed it in the documentation, thanks