/** * Prepares a connection object after its initialization. * * @param SingleConnectionInterface $connection Instance of a connection object. * @param ServerProfileInterface $profile $connection Instance of a connection object. */ protected function prepareConnection(SingleConnectionInterface $connection, ServerProfileInterface $profile) { $parameters = $connection->getParameters(); if (isset($parameters->password)) { $command = $profile->createCommand('auth', array($parameters->password)); $connection->pushInitCommand($command); } if (isset($parameters->database)) { $command = $profile->createCommand('select', array($parameters->database)); $connection->pushInitCommand($command); } }
/** * Returns the list of commands supported by the current * server profile. * * @param ServerProfileInterface $profile Server profile instance. * @return array */ protected function getCommands(ServerProfileInterface $profile) { $commands = $profile->getSupportedCommands(); return array_keys($commands); }
/** * @param ServerProfileInterface $profile Server profile. */ public function setProfile(ServerProfileInterface $profile) { if (!$profile->supportsCommands(array('multi', 'exec', 'discard'))) { throw new ClientException('The specified server profile must support MULTI, EXEC and DISCARD.'); } $this->profile = $profile; }