/**
  * @param string $key
  * @param Property $value
  * @param string $overwrite
  * @throws Exceptions\OverwriteKeyException
  * @return \JSONSchema\Structure\AbstractStructure
  */
 public function addProperty($key, Property $value, $requiredByDefault = false, $overwrite = true)
 {
     if (array_key_exists($key, $this->properties) === true && $overwrite === false) {
         throw new Exceptions\OverwriteKeyException();
     }
     $value->setId($this->getId() . '/' . $key);
     $this->properties[$key] = $value;
     if ($requiredByDefault === true) {
         $this->required[] = $key;
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * Добавляет новое свойство БД.
  * @global type $DB
  * @param \Property $property
  * @param string $tableName
  */
 static function insertProperty($property, $tableName)
 {
     global $DB;
     $sql = 'INSERT INTO ' . $tableName . ' (PARENT_ID, TYPE, VALUE) VALUES (' . $property->getParentId() . ', "' . $DB->EscapeString($property->getType()) . '", "' . $DB->EscapeString($property->getValue()) . '")';
     $DB->Query($sql);
     $property->setId($DB->LastID());
 }