/** * Inserts model to database * * @param string * @param Eden_Sql * @return this */ public function insert($table = NULL, Eden_Sql_Database $database = NULL) { if ($this->_data['user_slug'] && !$this->validSlug($this->_data['user_slug'])) { User_Error::i()->setMessage(User_Error::INVALID_SLUG)->addVariable($this->_data['user_slug'])->trigger(); } $this->_data['user_created'] = date('Y-m-d H:i:s'); $this->_data['user_updated'] = date('Y-m-d H:i:s'); parent::insert($table, $database); $this->_setRelations()->_setAttributes()->_addLeftRight($this->_data['user_id'], $this->_data['user_parent']); return $this; }
/** * Inserts model to database * * @param string * @param Eden_Sql * @return this */ public function insert($table = NULL, Eden_Sql_Database $database = NULL) { jobpost_Error::i()->argument(1, 'string', 'null'); //if jobpost user is set and it's a string if (isset($this->_data['jobpost_user']) && !is_numeric($this->_data['jobpost_user'])) { //get the user id and set it $this->_data['jobpost_user'] = $this->_database->getRow('user', 'user_name', $this->_data['jobpost_user']); $this->_data['jobpost_user'] = $this->_data['jobpost_user']['user_id']; } //if title is set if (isset($this->_data['jobpost_title'])) { $this->_data['jobpost_slug'] = $this->_getSlug($this->_data['jobpost_title']); } $this->_data['jobpost_created'] = date('Y-m-d H:i:s'); $this->_data['jobpost_updated'] = date('Y-m-d H:i:s'); parent::insert($table, $database); $this->_setRelations()->_setAttributes()->_addLeftRight($this->_data['jobpost_id'], $this->_data['jobpost_parent']); return $this; }