/** * @param Customer $customer */ public function changeDb($customer) { $refConn = new \ReflectionObject($this->connection); $refParams = $refConn->getProperty('_params'); $refParams->setAccessible('public'); //we have to change it for a moment $params = $refParams->getValue($this->connection); $params['dbname'] = $customer->getDbName(); $refParams->setAccessible('private'); $refParams->setValue($this->connection, $params); }