PhpOrient\Protocols\Binary\Data\Record::fromConfig PHP Method

fromConfig() public static method

Override the ConfigurableTrait fromConfig method to handle custom classes for records
public static fromConfig ( array $options = [] ) : mixed
$options array
return mixed
    public static function fromConfig(array $options = array())
    {
        // Get the custom fetch class name if available
        $fetchClass = PhpOrient::getFetchClass();
        if ($fetchClass) {
            $object = new $fetchClass();
        } else {
            $object = new self();
        }
        return $object->configure($options);
    }

Usage Example

 public function testCreateLoad()
 {
     if ($this->client->getTransport()->getProtocolVersion() < 26) {
         //            $this->markTestSkipped( 'Record Create/Update Unpredictable Behaviour' );
     }
     $rec1 = ['oData' => ['alloggio' => 'baita', 'lavoro' => 'no', 'vacanza' => 'lago']];
     $rec = Record::fromConfig($rec1);
     $result = $this->client->execute('recordCreate', ['cluster_id' => 9, 'record' => $rec]);
     $this->assertInstanceOf('\\PhpOrient\\Protocols\\Binary\\Data\\Record', $result);
     $this->assertEquals('#9:0', (string) $result->getRid());
     //        var_export( $result . "\n" );
     $rec2 = ['oData' => ['alloggio' => 'albergo', 'lavoro' => 'ufficio', 'vacanza' => 'montagna']];
     $rec = Record::fromConfig($rec2);
     $result = $this->client->execute('recordCreate', ['cluster_id' => 9, 'record' => $rec]);
     $this->assertInstanceOf('\\PhpOrient\\Protocols\\Binary\\Data\\Record', $result);
     $this->assertEquals('#9:1', (string) $result->getRid());
     //        var_export( $result . "\n" );
     $rec3 = ['alloggio' => 'case', 'lavoro' => 'mercato', 'vacanza' => 'mare'];
     $rec = new Record();
     $rec->setOData($rec3);
     $rec->setOClass('V');
     $result = $this->client->execute('recordCreate', ['cluster_id' => 9, 'record' => $rec]);
     $this->assertInstanceOf('\\PhpOrient\\Protocols\\Binary\\Data\\Record', $result);
     $this->assertEquals('#9:2', (string) $result->getRid());
     //        var_export( $result . "\n" );
     $load = $this->client->execute('recordLoad', ['rid' => $result->getRid()]);
     $this->assertInstanceOf('\\PhpOrient\\Protocols\\Binary\\Data\\Record', $load[0]);
     $this->assertEquals('#9:2', (string) $load[0]->getRid());
     $this->assertEquals((string) $rec, (string) $load[0]);
     //        var_export( $load[0] . "\n" );
 }
All Usage Examples Of PhpOrient\Protocols\Binary\Data\Record::fromConfig