/** * 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(); }
} return $this; } public function save(Validation $val = null) { if (!$this->loaded()) { $this->created = time();
public function save() { if (empty($this->moderation_status_id)) { $this->moderation_status_id = self::REVIEW_STATUS; } parent::save(); }
/** * 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; }
/** * 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(); }
public function save(Validation $validation = NULL) { if (!$this->loaded()) { //$this->maybe_notify(); } parent::save($validation); }
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(); }
public function save() { if (!empty($this->changed)) { $this->updated = time(); } return parent::save(); }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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(); }
/** * 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(); }
public function save() { if (empty($this->code)) { $this->code = sha1($this->title . $this->created . $this->user_id); } parent::save(); }
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); }
/** * 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); }
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(); }
/** * 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); }
/** * 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(); }
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); }
/** * 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(); }
public function save(Validation $validation = NULL) { if (!$this->loaded()) { // default subscribed $this->subscribed = 1; } parent::save($validation); }
/** * 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; }
/** * 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(); }
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); }
/** * 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(); }
/** * 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(); }
/** * 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); }