Changing connection through Builder

In my project it is very hard to use models for making queries. So I.m trying to do it using Builder. But I need to make queries in 2 or 3 different databases. So how can I switch connection or set connection service through Builder or modelManager?



83.4k

Queries built with the QueryBuilder also use models since it internally builds a PHQL statement which eventually will request the read connection from the used models. You could better access the database connection directly from the DI:

$result = $this->db1->query('SELECT ...');
$result = $this->db2->query('SELECT ...');

Ok, thank you!