Esempio n. 1
0
 /**
  * @param $sql
  * @return bool|\mysqli_result
  */
 protected function runQuery($sql)
 {
     $mysqli = $this->database->getMysqli();
     $result = $mysqli->query($sql);
     self::$logger->debug("Ran query: " . $sql);
     if (!$result) {
         self::fail($mysqli->error);
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * @param $obj
  * @param $parentId
  * @param $fkField TableField
  * @return mixed
  */
 private function persistEntity($obj, $parentId = null, $fkField = null)
 {
     $query = $this->table->getCreateSQL($obj, $parentId, $fkField);
     $this->runQuery($query);
     if ($this->table->getPrimaryKeyField()->isAutoIncrement()) {
         $insertId = $this->database->getMysqli()->insert_id;
         $this->setIdValue($obj, $insertId);
     }
     $this->setVersion($obj);
     $this->persistReferences($obj);
     $this->setCache($obj);
     return $this->getIdValue($obj);
 }