Doctrine\OrientDB\Binding\HttpBinding::command PHP Méthode

command() public méthode

public command ( $query, $language = BindingInterface::LANGUAGE_SQLPLUS, $database = null )
    public function command($query, $language = BindingInterface::LANGUAGE_SQLPLUS, $database = null)
    {
        $database = $database ?: $this->database;
        $this->ensureDatabase($database);
        $location = $this->getLocation('command', $database, array($language, $query));
        return $this->adapter->request('POST', $location);
    }

Usage Example

 public function testOptionalDatabaseArgumentDoesNotSwitchCurrentDatabase()
 {
     $host = TEST_ODB_HOST;
     $port = TEST_ODB_PORT;
     $database = TEST_ODB_DATABASE;
     $adapter = $this->getMock('Doctrine\\OrientDB\\Binding\\Adapter\\HttpClientAdapterInterface');
     $adapter->expects($this->at(0))->method('request')->with('POST', "http://{$host}:{$port}/command/{$database}/sql/SELECT%201", null, null);
     $adapter->expects($this->at(1))->method('request')->with('POST', "http://{$host}:{$port}/command/HIJACKED/sql/SELECT%202", null, null);
     $adapter->expects($this->at(2))->method('request')->with('POST', "http://{$host}:{$port}/command/{$database}/sql/SELECT%203", null, null);
     $parameters = new BindingParameters(TEST_ODB_HOST, TEST_ODB_PORT, TEST_ODB_USER, TEST_ODB_PASSWORD, TEST_ODB_DATABASE);
     $binding = new HttpBinding($parameters);
     $binding->setAdapter($adapter);
     $binding->command('SELECT 1');
     $binding->command('SELECT 2', HttpBinding::LANGUAGE_SQLPLUS, "HIJACKED");
     $binding->command('SELECT 3');
 }