• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Switch Sqlite3 DB - $db->setDatabase

#4
I have been exclusively using default so found this interesting in config/Database.php

i used $custom = [ etc etc ];

but then in a controller for a quick test i used:

$db = \Config\Database::connect('custom');

//$db = \Config\Database::connect($custom); gave me an error


$query = $db->query('SELECT * FROM blog');
$results = $query->getResultArray();

foreach ($results as $row)
{
echo $row['title'];
echo $row['article'];

}





then i found it connected and i retrieved db entries
Reply


Messages In This Thread
Switch Sqlite3 DB - $db->setDatabase - by s4f3r - 08-13-2020, 05:31 AM
RE: Switch Sqlite3 DB - $db->setDatabase - by captain-sensible - 08-14-2020, 01:57 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.