if you create a new DB\SQL in your baseModel, then every new class instance your're using, would probably create a new DB connection. And many connections leads to bad performance. So better is to start the connection once and save it in a framework var DB, and fetch this in your baseModel with a simple $this->db = $this->f3->get('DB');
Would you start the db connection in index.php?
If you put the db in a class, could you write it in a singleton pattern so it checks if it already exists before creating a new connection?
So... as is shown in the CMS example, each function you create needs to call the f3 instance & the db connection so it can work with those?
or is the alternative to put the vars $f & $db as arguments of each function because the framework already passes them in to each function as part of routing?
function yoMomma($f3, $db)
{ $f3->get('clean_underwear');
$db->exec('select * from laundry');
// etc...
}
but if a function is not called from routing, ie.. a static function that can be called from inside routing functions, then they won't have implicit access to the $f3 var, and you need to either fetch it from inside the static function (as shown in the CMS example), or you pass $f3 as an argument to the static function when it is called?
// call static func
$wm_status = WashingMachine::status($f3,$db);