Esempio n. 1
0
 public function save($deep = true)
 {
     if (!$this->Key) {
         $this->Key = static::generateUniqueKey();
     }
     parent::save($deep);
 }
Esempio n. 2
0
 public function save($deep = true)
 {
     parent::save($deep);
     if (($this->isUpdated || $this->isNew) && $this->EndpointID) {
         Cache::delete("endpoints/{$this->EndpointID}/rewrites");
     }
 }
Esempio n. 3
0
 public function save($deep = true)
 {
     parent::save($deep);
     if (($this->isUpdated || $this->isNew) && $this->KeyID) {
         Cache::delete("keys/{$this->KeyID}/endpoints");
     }
 }
Esempio n. 4
0
 public function save($deep = true)
 {
     parent::save($deep);
     if ($this->isUpdated || $this->isNew) {
         Cache::delete('bans');
     }
 }
Esempio n. 5
0
 public function save($deep = true)
 {
     // set handle
     if (!$this->Handle) {
         $this->Handle = strtolower(static::getUniqueHandle($this->Title));
     }
     return parent::save($deep);
 }
Esempio n. 6
0
 public function save($new = false, $primary = 'id')
 {
     if (parent::save($new, $primary)) {
         $_SESSION['usr']['upd'] = 1;
         return true;
     } else {
         return false;
     }
 }
Esempio n. 7
0
 public function save()
 {
     // set handle
     if (!$this->Handle) {
         $this->Handle = static::getUniqueHandle($this->Title);
     }
     // call parent
     parent::save();
 }
Esempio n. 8
0
 public function save($deep = true)
 {
     // set code
     if (!$this->Code) {
         $this->Code = \HandleBehavior::getUniqueHandle($this, $this->Title, ['handleField' => 'Code']);
     }
     // call parent
     parent::save($deep);
 }
Esempio n. 9
0
 public function save($deep = true)
 {
     if (!$this->Opened) {
         $this->Opened = time();
     }
     if ($this->isFieldDirty('Status') && $this->Status == 'closed' && !$this->Closed) {
         $this->Closed = time();
     }
     parent::save($deep);
 }
Esempio n. 10
0
 protected function saveModel(ActiveRecord $model, $web_url)
 {
     if ($model->save()) {
         $model->grabImages($web_url);
         $model->grabTagsFromText();
         $this->log("Сохранена модель #{$model->id}");
     } else {
         $this->log("Не могу сохранить модель: ", impode("<br/>", $model->errors_flat_array));
     }
     return $model;
 }
Esempio n. 11
0
 public function save($deep = true)
 {
     // set handle
     if (!$this->Handle) {
         $this->Handle = HandleBehavior::generateRandomHandle($this);
     }
     if (!$this->Expires) {
         $this->Expires = time() + 3600 * static::$expirationHours;
     }
     // call parent
     parent::save($deep);
 }
 public function save($deep = true)
 {
     // set handle
     if (!$this->Handle) {
         $this->Handle = HandleBehavior::generateRandomHandle($this, 4);
     }
     // update PK
     if (!$this->ContextID && $this->Context && !$this->Context->isPhantom) {
         $this->ContextID = $this->Context->ID;
     }
     // call parent
     parent::save($deep);
 }
Esempio n. 13
0
 public function save($forceOperation = null)
 {
     $this->executePlugins($this, 'before-save');
     if ($this instanceof EavAble && $this->eavObject->get() && !$this->eavObject->get()->getID() && $this->isSpecificationLoaded() && $this->getSpecification()->hasValues()) {
         $eavObject = $this->eavObject->get();
         $this->eavObject->setNull();
     }
     $res = parent::save($forceOperation);
     if (isset($eavObject)) {
         $eavObject->save();
         $this->eavObject->set($eavObject);
         $this->save();
     }
     if ($this instanceof EavAble && $this->specificationInstance && $this->eavObject->get()) {
         if ($this->specificationInstance->hasValues()) {
             $this->specificationInstance->save();
         } else {
             $this->eavObject->get()->delete();
         }
     }
     $this->executePlugins($this, 'after-save');
     return $res;
 }
Esempio n. 14
0
 public function save($deep = true)
 {
     HandleBehavior::onSave($this, $this->Headline);
     parent::save($deep);
 }
Esempio n. 15
0
<?php

require_once 'activerecord.php';
$ar = new ActiveRecord();
$ar->connectPdo('blogdb', 'blog', $_POST['username'], $_POST['password']);
$postid = $ar->size() + 1;
$ar->pagenum = $postid;
$ar->author = $_POST['username'];
$ar->date = date('Y/m/d');
$ar->title = $_POST['title'];
$ar->text = nl2br($_POST['text']);
try {
    $ar->save();
} catch (Exception $e) {
    echo $e->getMessage();
    return;
}
$ar->connectPdo('blogdb', 'categorytable', $_POST['username'], $_POST['password']);
$categories = explode(',', $_POST["category"]);
foreach ($categories as $category) {
    $ar->postid = $postid;
    $ar->category = $category;
    try {
        $ar->save();
    } catch (Exception $e) {
        echo $e->getMessage();
        $ar->connectPdo('blogdb', 'blog', $_POST['username'], $_POST['password']);
        $postid = $ar->size();
        $ar->delete($postid);
        return;
    }
Esempio n. 16
0
 public function save($deep = true)
 {
     // set handle
     if (!$this->Handle) {
         $this->Handle = HandleBehavior::generateRandomHandle($this);
     }
     // call parent
     parent::save($deep);
     // set cookie
     setcookie(static::$cookieName, $this->Handle, static::$cookieExpires ? time() + static::$cookieExpires : 0, static::$cookiePath, static::$cookieDomain, static::$cookieSecure);
 }
Esempio n. 17
0
 /**
  * Update "current" translation object
  * @param ActiveRecord $translate
  */
 public function updateTranslation($translate)
 {
     foreach ($this->translateAttributes as $attr) {
         $translate->{$attr} = $this->owner->{$attr};
     }
     $translate->save(false, false, false);
 }
Esempio n. 18
0
 public function save($deep = true)
 {
     HandleBehavior::onSave($this, $this->Title);
     return parent::save(true);
 }
Esempio n. 19
0
 public function save($forceOperation = null)
 {
     $this->executePlugins($this, 'before-save');
     if ($this instanceof EavAble && $this->eavObject->get() && !$this->eavObject->get()->getID() && $this->isSpecificationLoaded() && $this->getSpecification()->hasValues()) {
         $eavObject = $this->eavObject->get();
         $this->eavObject->setNull();
     }
     $res = parent::save($forceOperation);
     if (isset($eavObject)) {
         $eavObject->save();
         $this->eavObject->set($eavObject);
         $this->save();
     }
     if ($this instanceof EavAble && $this->specificationInstance && $this->eavObject->get()) {
         if ($this->specificationInstance->hasValues()) {
             $this->specificationInstance->save();
         } else {
             $this->eavObject->get()->delete();
         }
     }
     $this->executePlugins($this, 'after-save');
     $cache = self::getApplication()->getCache();
     if ($cache instanceof MemCachedCache) {
         $cache->set($this->getRecordIdentifier($this), $this);
     }
     return $res;
 }
 public function save($deep = true)
 {
     $wasDirty = false;
     if ($this->isDirty) {
         $wasDirty = true;
     }
     // save record as usual
     $return = parent::save($deep);
     if ($wasDirty) {
         // save a copy to history table
         $recordValues = $this->_prepareRecordValues();
         // maintain legacy behavior if trackModified is disabled and overwrite Creator
         if (!static::$trackModified) {
             $recordValues['Created'] = 'CURRENT_TIMESTAMP';
             $recordValues['CreatorID'] = !empty($_SESSION) && !empty($_SESSION['User']) ? $_SESSION['User']->ID : null;
         }
         $set = static::_mapValuesToSet($recordValues);
         DB::nonQuery('INSERT INTO `%s` SET %s', array(static::getHistoryTableName(), join(',', $set)));
     }
 }
Esempio n. 21
0
 function save()
 {
     $this->discountIfInternalProject();
     parent::save();
 }