public function __get($name) { // lazy loading LINK and LINKLIST if (is_a($this->getAttribute($name), 'PhpOrient\\Protocols\\Binary\\Data\\ID') || $this->isArrayOfRid($this->getAttribute($name))) { if ($relation = $this->getRelation($name, false)) { if (!$relation->embedded) { if ($relation->multiple) { $rids = $this->getAttribute($name); $ridsResult = []; foreach ($rids as $rid) { array_push($ridsResult, DataRreaderOrientDB::IDtoRid($rid)); } $relation->andWhere(['in', '@rid', $ridsResult]); // load relation data: $this->{$name} = $relation->all(); $this->populateRelation($name, $this); // return $this->$name; } else { $rid = $this->getAttribute($name); $relation->andWhere(['=', '@rid', DataRreaderOrientDB::IDtoRid($rid)]); // load relation data: $this->{$name} = $relation->one(); $this->populateRelation($name, $this); // return $this->$name; } } } } return parent::__get($name); }
public function execute() { $sql = $this->getSql(); $rawSql = $this->getRawSql(); Yii::info($rawSql, __METHOD__); if ($sql == '') { return 0; } $token = $rawSql; try { Yii::beginProfile($token, 'yii\\db\\Command::query'); $n = $this->db->command($rawSql); Yii::endProfile($token, 'yii\\db\\Command::query'); if (is_a($n, 'PhpOrient\\Protocols\\Binary\\Data\\Record')) { return DataRreaderOrientDB::getRecordData($n); // insert return record } return $n; // update return '0' of '1' } catch (\Exception $e) { Yii::endProfile($token, __METHOD__); throw new OrientDBException(__CLASS__ . " databse return error: " . $e->getMessage() . ", When execute sql: " . $rawSql); } }
public function one($db = null) { $this->limit = 1; $command = $this->createCommand($db); if (!empty($this->fetch_plan)) { $command->setFetch_plan($this->fetch_plan); $rows = (new DataRreaderOrientDB($command->queryOne()))->getTree(); if (!empty($rows) && !empty($rows[0])) { return $rows[0]; } } else { $rows = $command->queryOne(); if (isset($rows['records'][0])) { return DataRreaderOrientDB::getRecordData($rows['records'][0]); } } return null; }