setOClass() public method

Sets the Orient Class
public setOClass ( string $oClass )
$oClass string
Example #1
0
 public function testUpdate()
 {
     $config = static::getConfig();
     $this->client = new PhpOrient();
     $this->client->configure(array('username' => $config['username'], 'password' => $config['password'], 'hostname' => $config['hostname'], 'port' => $config['port']));
     $this->client->dbOpen($this->db_name, 'admin', 'admin');
     $tx = $this->client->getTransactionStatement();
     $this->assertInstanceOf('PhpOrient\\Protocols\\Binary\\Transaction\\TxCommit', $tx);
     $tx = $tx->begin();
     $this->assertInstanceOf('PhpOrient\\Protocols\\Binary\\Transaction\\TxCommit', $tx);
     $recUp = ['accommodation' => 'mountain cabin'];
     $rec2 = new Record();
     $rec2->setOData($recUp);
     $rec2->setOClass('V');
     $rec2->setRid($this->first_rec->getRid());
     $rec2->setVersion($this->first_rec->getVersion());
     $updateCommand = $this->client->recordUpdate($rec2);
     //UPDATE AGAIN!!!
     $recUp = ['accommodation' => 'mountain cabin 2'];
     $rec3 = new Record();
     $rec3->setOData($recUp);
     $rec3->setOClass('V');
     $rec3->setRid($this->first_rec->getRid());
     $rec3->setVersion($this->first_rec->getVersion());
     $updateCommand = $this->client->recordUpdate($rec3);
     $createCommand = $this->client->recordCreate((new Record())->setOData(['accommodation' => 'bungalow'])->setOClass('V')->setRid(new ID(9)));
     //CREATE ANOTHER ONE
     $createCommand2 = $this->client->recordCreate((new Record())->setOData(['accommodation' => 'under the sky'])->setOClass('V')->setRid(new ID(9)));
     $deleteCommand = $this->client->recordDelete($this->sec_rec->getRid());
     $this->assertInstanceOf('PhpOrient\\Protocols\\Binary\\operations\\RecordUpdate', $updateCommand);
     $tx->attach($updateCommand);
     $tx->attach($createCommand);
     $tx->attach($createCommand2);
     $tx->attach($deleteCommand);
     $result = $tx->commit();
     /**
      * @var Record $record
      */
     foreach ($result as $record) {
         if ($record->getRid() == $this->first_rec->getRid()) {
             $this->assertEquals($record->getOData(), ['accommodation' => 'mountain cabin 2']);
             $this->assertEquals($record->getOClass(), $this->first_rec->getOClass());
         } elseif ($record->getRid()->__toString() == '#9:2') {
             $this->assertEquals($record->getOData(), ['accommodation' => 'bungalow']);
             $this->assertEquals($record->getOClass(), 'V');
         } elseif ($record->getRid()->__toString() == '#9:3') {
             $this->assertEquals($record->getOData(), ['accommodation' => 'under the sky']);
             $this->assertEquals($record->getOClass(), 'V');
         }
     }
     //check for deleted record
     $deleted = $this->client->recordLoad($this->sec_rec->getRid());
     $this->assertEmpty($deleted);
 }
Example #2
0
 public function testVersionProperty()
 {
     $this->markTestSkipped('PupĆ¹');
     $recOrig = ['name' => 'foo', 'version' => '1.0.0'];
     $rec = new Record();
     $rec->setOData($recOrig);
     $rec->setOClass('Package');
     $rec->setRid(new ID(9));
     $result = $this->client->recordCreate($rec);
     var_export($result);
     $result = $this->client->query('select from V');
     var_export($result);
 }
 public function testHiLevelCreateDelete()
 {
     $config = static::getConfig();
     $this->client = new PhpOrient();
     $this->client->configure(array('username' => $config['username'], 'password' => $config['password'], 'hostname' => $config['hostname'], 'port' => $config['port']));
     $this->client->dbOpen($this->db_name, 'admin', 'admin');
     $recOrig = ['accommodation' => 'case', 'work' => 'mercato', 'holiday' => 'mare'];
     $rec = new Record();
     $rec->setOData($recOrig);
     $rec->setOClass('V');
     $rec->setRid(new ID(9));
     $result = $this->client->recordCreate($rec);
     $this->assertInstanceOf('\\PhpOrient\\Protocols\\Binary\\Data\\Record', $result);
     $this->assertEquals('#9:0', (string) $result->getRid());
     $this->assertEquals('9', $result->getRid()->cluster);
     $this->assertEquals('0', $result->getRid()->position);
     $load = $this->client->recordLoad($result->getRid());
     $this->assertInstanceOf('\\PhpOrient\\Protocols\\Binary\\Data\\Record', $load[0]);
     $this->assertEquals((string) $result->getRid(), (string) $load[0]->getRid());
     $this->assertEquals((string) $result, (string) $load[0]);
     $_recUp = ['accommodation' => 'hotel', 'work' => 'office', 'holiday' => 'mountain'];
     $recUp = (new Record())->setOData($_recUp)->setOClass('V')->setRid($result->getRid());
     $updated0 = $this->client->recordUpdate($recUp);
     $this->assertInstanceOf('\\PhpOrient\\Protocols\\Binary\\Data\\Record', $updated0);
     $delete = $this->client->recordDelete($load[0]->getRid());
     $this->assertTrue($delete);
     //try load again, this should be empty
     $reLoad = $this->client->recordLoad($result->getRid());
     $this->assertEmpty($reLoad);
     $result = $this->client->dataClusterCount([9]);
     $this->assertEmpty($result);
 }