Predis\Connection\WebdisConnection::executeCommand PHP Méthode

executeCommand() public méthode

public executeCommand ( Predis\Command\CommandInterface $command )
$command Predis\Command\CommandInterface
    public function executeCommand(CommandInterface $command)
    {
        $resource = $this->resource;
        $commandId = $this->getCommandId($command);
        if ($arguments = $command->getArguments()) {
            $arguments = implode('/', array_map('urlencode', $arguments));
            $serializedCommand = "{$commandId}/{$arguments}.raw";
        } else {
            $serializedCommand = "{$commandId}.raw";
        }
        curl_setopt($resource, CURLOPT_POSTFIELDS, $serializedCommand);
        if (curl_exec($resource) === false) {
            $error = trim(curl_error($resource));
            $errno = curl_errno($resource);
            throw new ConnectionException($this, "{$error}{$this->getParameters()}]", $errno);
        }
        if (phpiredis_reader_get_state($this->reader) !== PHPIREDIS_READER_STATE_COMPLETE) {
            throw new ProtocolException($this, phpiredis_reader_get_error($this->reader));
        }
        return phpiredis_reader_get_reply($this->reader);
    }

Usage Example

 /**
  * Returns a new instance of a connection instance.
  *
  * @param  mixed            $profile    Redis profile.
  * @param  array            $parameters Additional connection parameters.
  * @return WebdisConnection
  */
 protected function getConnection(&$profile = null, array $parameters = array())
 {
     $parameters = $this->getParameters($parameters);
     $profile = $this->getProfile();
     $connection = new WebdisConnection($parameters);
     $connection->executeCommand($profile->createCommand('flushdb'));
     return $connection;
 }
All Usage Examples Of Predis\Connection\WebdisConnection::executeCommand