I have an app that has individual db for each user, like user_1, user_2, etc.

So, I use:

$connection = new DbAdapter(array(
        'host' => $config->database->host,
        'username' => $config->database->username,
        'password' => $config->database->password,
        'dbname' => 'user_' . $user->id,
        'charset' => 'utf8'
    ));

It works ok. But now I need to iterate a function through all my databases, like:

    foreach ($users as $user) {
        $this->db->setDB('user_'.$user->id);   // HOW TO DO THIS?
        $page = Page::find();  // will be SELECT ... FROM user_1.pages ...
        // ...
    }