save() public method

Save any fields which have been modified on this object to the database.
public save ( )
Exemplo n.º 1
0
 /**
  * Create operation
  *
  * @param  array $data
  * @return ORM
  */
 public function create(array $data = array())
 {
     foreach ($data as $column => $value) {
         $this->orm->set($column, $value);
     }
     return $this->orm->save();
 }
Exemplo n.º 2
0
     }
     return $this;
 }
 public function save(Validation $val = null)
 {
     if (!$this->loaded()) {
         $this->created = time();
Exemplo n.º 3
0
 public function save()
 {
     if (empty($this->moderation_status_id)) {
         $this->moderation_status_id = self::REVIEW_STATUS;
     }
     parent::save();
 }
Exemplo n.º 4
0
 /**
  * Override the save method to clear cache
  */
 public function save(Validation $validation = NULL)
 {
     parent::save($validation);
     //cleanup the cache
     Cache::instance('roles')->delete_all();
     return $this;
 }
Exemplo n.º 5
0
 /**
  * Overload saving to set the created time and to create a new token
  * when the object is saved.
  */
 public function save()
 {
     if ($this->loaded === FALSE) {
         $this->time = time();
     }
     return parent::save();
 }
Exemplo n.º 6
0
 public function save(Validation $validation = NULL)
 {
     if (!$this->loaded()) {
         //$this->maybe_notify();
     }
     parent::save($validation);
 }
Exemplo n.º 7
0
 public function save()
 {
     if (array_key_exists($this->_columns['password'], $this->_changed)) {
         $this->_object[$this->_columns['password']] = A1::instance($this->_config)->hash_password($this->_object[$this->_columns['password']]);
     }
     return parent::save();
 }
Exemplo n.º 8
0
 public function save()
 {
     if (!empty($this->changed)) {
         $this->updated = time();
     }
     return parent::save();
 }
Exemplo n.º 9
0
 /**
  * Overload ORM::save() to update the MPTT tree when we add new items to the hierarchy.
  *
  * @chainable
  * @return  ORM
  */
 function save()
 {
     if (!$this->loaded()) {
         $this->lock();
         $parent = ORM::factory("item", $this->parent_id);
         try {
             // Make a hole in the parent for this new item
             db::build()->update($this->table_name)->set("left_ptr", new Database_Expression("`left_ptr` + 2"))->where("left_ptr", ">=", $parent->right_ptr)->execute();
             db::build()->update($this->table_name)->set("right_ptr", new Database_Expression("`right_ptr` + 2"))->where("right_ptr", ">=", $parent->right_ptr)->execute();
             $parent->right_ptr += 2;
             // Insert this item into the hole
             $this->left_ptr = $parent->right_ptr - 2;
             $this->right_ptr = $parent->right_ptr - 1;
             $this->parent_id = $parent->id;
             $this->level = $parent->level + 1;
         } catch (Exception $e) {
             $this->unlock();
             throw $e;
         }
         parent::save();
         $this->unlock();
     } else {
         parent::save();
     }
     return $this;
 }
Exemplo n.º 10
0
 /**
  * Overload ORM::save() to trigger an item_related_update event for all items that are related
  * to this tag.
  */
 public function save()
 {
     // Check to see if another tag exists with the same name
     $duplicate_tag = ORM::factory("tag")->where("name", "=", $this->name)->where("id", "!=", $this->id)->find();
     if ($duplicate_tag->loaded()) {
         // If so, tag its items with this tag so as to merge it
         $duplicate_tag_items = ORM::factory("item")->join("items_tags", "items.id", "items_tags.item_id")->where("items_tags.tag_id", "=", $duplicate_tag->id)->find_all();
         foreach ($duplicate_tag_items as $item) {
             $this->add($item);
         }
         // ... and remove the duplicate tag
         $duplicate_tag->delete();
     }
     if (isset($this->object_relations["items"])) {
         $added = array_diff($this->changed_relations["items"], $this->object_relations["items"]);
         $removed = array_diff($this->object_relations["items"], $this->changed_relations["items"]);
         if (isset($this->changed_relations["items"])) {
             $changed = array_merge($added, $removed);
         }
         $this->count = count($this->object_relations["items"]) + count($added) - count($removed);
     }
     $result = parent::save();
     if (!empty($changed)) {
         foreach (ORM::factory("item")->where("id", "IN", $changed)->find_all() as $item) {
             module::event("item_related_update", $item);
         }
     }
     return $result;
 }
Exemplo n.º 11
0
 /**
  * Overload saving to perform additional functions on the channel_filter
  */
 public function save(Validation $validation = NULL)
 {
     $ret = parent::save();
     // Run post_save events
     Swiftriver_Event::run('swiftriver.channel.option.post_save', $this);
     return $ret;
 }
Exemplo n.º 12
0
 /**
  * Overload saving to set the created time and to create a new token
  * when the object is saved.
  */
 public function save()
 {
     if ($this->loaded === FALSE) {
         #TODO: increase the post reply count by one.
     }
     return parent::save();
 }
Exemplo n.º 13
0
 /**
  * Overload saving to set the created time and to create a new token
  * when the object is saved.
  */
 public function save()
 {
     if ($this->loaded === FALSE) {
     }
     $this->token = $this->create_token();
     return parent::save();
 }
Exemplo n.º 14
0
 public function save()
 {
     if (empty($this->code)) {
         $this->code = sha1($this->title . $this->created . $this->user_id);
     }
     parent::save();
 }
Exemplo n.º 15
0
 public function save(Validation $validation = NULL)
 {
     $this->user_id = User::active_user()->id;
     $this->client_id = sha1($this->user_id . uniqid() . microtime());
     $this->client_secret = sha1($this->user_id . uniqid() . microtime());
     return parent::save($validation);
 }
Exemplo n.º 16
0
 /**
  * Save
  * @param Validation $validation
  * @return ORM
  */
 public function save(Validation $validation = null)
 {
     if ($this->slug == '') {
         $this->slug = $this->get_unique_slug($this->title);
     }
     return parent::save($validation);
 }
 public function save()
 {
     if (is_array($this->data)) {
         $this->data = json_encode($this->data);
     }
     parent::save();
     $this->data = json_decode($this->data, TRUE);
 }
Exemplo n.º 18
0
 public function save()
 {
     if (!$this->loaded) {
         $this->date = date("Y-m-d H:i:s");
     }
     $this->modified = date("Y-m-d H:i:s");
     parent::save();
 }
Exemplo n.º 19
0
 /**
  * Automatically 'touch' the related topic if needed.
  *
  * @param Validation $validation
  * @param bool $touch_topic
  * @return ORM
  */
 public function save(Validation $validation = null, $touch_topic = false)
 {
     if ($touch_topic == true) {
         $this->topic->updated_at = time();
         $this->topic->save();
     }
     return parent::save($validation);
 }
Exemplo n.º 20
0
 /**
  * Overload saving to perform additional functions on the place
  */
 public function save(Validation $validation = NULL)
 {
     $this->id = self::get_ids(1);
     $this->place_name = trim($this->place_name);
     $this->place_name_canonical = strtolower($this->place_name);
     $this->hash = md5($this->place_name . $this->longitude . $this->latitude);
     return parent::save();
 }
Exemplo n.º 21
0
 public function save(Validation $validation = NULL)
 {
     if (!$this->loaded()) {
         $this->hash = Text::random('alnum', rand(24, 32));
         $this->created = time();
     }
     return parent::save($validation);
 }
 public function save(Validation $validation = NULL)
 {
     if (!$this->loaded()) {
         $this->date_created = DB::expr('NOW()');
     }
     $this->date_updated = DB::expr('NOW()');
     return parent::save($validation);
 }
Exemplo n.º 23
0
 /**
  * Overload saving to set the created time when the object is saved.
  */
 public function save()
 {
     if ($this->loaded === FALSE) {
         // Set the created time
         $this->created = $this->now;
     }
     return parent::save();
 }
Exemplo n.º 24
0
 public function save(Validation $validation = NULL)
 {
     if (!$this->loaded()) {
         // default subscribed
         $this->subscribed = 1;
     }
     parent::save($validation);
 }
Exemplo n.º 25
0
 /**
  * Get saved.
  *
  * @return  ORM
  */
 public function save()
 {
     if (array_key_exists('geometry', $this->_changed)) {
         $this->_object['geometry'] = DB::expr(sprintf('ST_SetSRID(ST_GeometryFromText(%s), %d)', $this->_db->quote($this->_object['geometry']), Sourcemap::PROJ));
     }
     parent::save();
     $this->reload();
     return $this;
 }
Exemplo n.º 26
0
 /**
  * Overload saving to perform additional functions on the tag
  */
 public function save(Validation $validation = NULL)
 {
     $this->id = self::get_ids(1);
     $this->tag = trim($this->tag);
     $this->tag_canonical = strtolower($this->tag);
     $this->tag_type = strtolower(trim($this->tag_type));
     $this->hash = md5($this->tag . $this->tag_type);
     return parent::save();
 }
Exemplo n.º 27
0
 public function save(Validation $validation = null)
 {
     if ($this->parent->loaded()) {
         $this->level = $this->parent->level + 1;
     }
     $this->md5_url = md5($this->url);
     $this->updated_at = date('Y-m-d H:i:s');
     return parent::save($validation);
 }
Exemplo n.º 28
0
 /**
  * Overload saving to set the created time and to create a new token
  * when the object is saved.
  */
 public function save()
 {
     if (!$this->loaded) {
         # when the user is first created, assign a token for him.
         # we may not even need this for account_users though!!
         $this->token = $this->create_token();
     }
     return parent::save();
 }
Exemplo n.º 29
0
 /**
  * Overload saving to perform additional functions on the follower
  */
 public function save(Validation $validation = NULL)
 {
     // Do this for first time followers only
     if ($this->loaded() === FALSE) {
         // Save the date the follower was first added
         $this->follower_date_add = date("Y-m-d H:i:s", time());
     }
     return parent::save();
 }
Exemplo n.º 30
0
 /**
  * Updates or Creates the record depending on loaded()
  *
  * @param   Validation $validation Validation object [Optional]
  * @return  ORM
  */
 public function save(Validation $validation = NULL)
 {
     if (is_array($this->roles) and count($this->roles) > 0) {
         $this->roles = implode(',', $this->roles);
     } else {
         $this->roles = NULL;
     }
     return parent::save($validation);
 }