/** * overloads RoxEntityBase::update * * @access public * @return int */ public function update() { if ($status = parent::update()) { $data = array(); foreach ($this->blog_data_columns as $column) { if ($this->{$column}) { $data[$column] = $this->dao->escape($this->{$column}); } } if (!empty($data)) { $set = array(); foreach ($data as $key => $value) { $set[] = "{$key} = '{$value}'"; } $set = implode(', ', $set); $query = "UPDATE blog_data SET {$set} WHERE blog_id = {$this->getPKValue()}"; $status = !!$this->dao->query($query); } } return $status; }
public function update($status = false) { if ($status) { $this->laststatechanged = date('Y-m-d'); switch ($this->state) { case SuggestionsModel::SUGGESTIONS_VOTING: $this->notifyVotingStarted(); break; case SuggestionsModel::SUGGESTIONS_RANKING: $this->calculateResults(); // $this->state = SuggestionsModel::SUGGESTIONS_VOTING; break; } return parent::update(); } else { // update all fields except for the status field // as this might have changed in the mean time $query = "\n UPDATE\n suggestions\n SET\n summary = '" . $this->dao->escape($this->summary) . "',\n description = '" . $this->dao->escape($this->description) . "',\n modified = NOW(),"; // Check if flags is set and ensure correct value if ($this->flags) { $query .= " `flags` = " . $this->dao->escape($this->flags); } else { $query .= " `flags` = 0"; } $query .= ",\n modifiedby = " . $this->getLoggedInMember()->id . "\n WHERE\n id = " . $this->id; $this->dao->query($query); } }