The object's internal variable will also be updated.
If the value hasnt changed, the database will not be updated.
Note: You cannot set $p_commit to FALSE and $p_isSql to TRUE
at the same time.
public setProperty ( string $p_dbColumnName, string $p_value, boolean $p_commit = true, boolean $p_isSql = false ) : boolean | ||
$p_dbColumnName | string | The name of the column that is to be updated. |
$p_value | string | The value to set. |
$p_commit | boolean | If set to true, the value will be written to the database immediately. If set to false, the value will not be written to the database. Default is true. |
$p_isSql | boolean | Set this to TRUE if p_value consists of SQL commands. There is no way to know what the result of the command is, so we will need to refetch the value from the database in order to update the internal variable's value. |
Результат | boolean | TRUE on success, FALSE on error. |
/** * Wrapper around DatabaseObject::setProperty * @see classes/DatabaseObject#setProperty($p_dbColumnName, $p_value, $p_commit, $p_isSql) */ public function setProperty($p_dbColumnName, $p_value, $p_commit = true, $p_isSql = false) { if ($p_dbColumnName == 'Name') { $this->m_keyColumnNames = array('Name'); $this->resetCache(); $this->m_keyColumnNames = array('Id'); } return parent::setProperty($p_dbColumnName, $p_value); }
/** * Wrapper around DatabaseObject::setProperty * * @see classes/DatabaseObject#setProperty($p_dbColumnName, $p_value, $p_commit, $p_isSql) */ public function setProperty($p_dbColumnName, $p_value, $p_commit = true, $p_isSql = false) { if ($p_dbColumnName == 'Number') { $this->m_keyColumnNames = array('NrArticle', 'Number'); $this->resetCache(); $this->m_keyColumnNames = array('NrArticle', 'IdImage'); } return parent::setProperty($p_dbColumnName, $p_value); } // fn setProperty
function setProperty($p_name, $p_value) { $result = parent::setProperty($p_name, $p_value); if ($p_name == 'status' || $p_name == 'admin_status') { BlogEntry::TriggerCounters($this->getProperty('fk_entry_id')); } $CampCache = CampCache::singleton(); $CampCache->clear('user'); return $result; }
/** * @param string value */ public function setUrlName($p_value) { $this->m_cacheUpdate = true; return parent::setProperty('ShortName', $p_value); } // fn setUrlName
/** * Method to call parent::setProperty * with clening the cache. * * @param string $p_name * @param sring $p_value */ function setProperty($p_name, $p_value) { $return = parent::setProperty($p_name, $p_value); $CampCache = CampCache::singleton(); $CampCache->clear('user'); return $return; }
/** * @param string value */ public function setUrlName($p_value) { return parent::setProperty('ShortName', $p_value); }
public function setProperty($p_dbColumnName, $p_value, $p_commit = true, $p_isSql = false) { if (!in_array($p_dbColumnName, $this->m_columnNames)) { return false; } $articleField = new ArticleTypeField($this->m_articleTypeName, substr($p_dbColumnName, 1)); if ($articleField->getType() == ArticleTypeField::TYPE_BODY) { // Replace <span class="subhead"> ... </span> with <!** Title> ... <!** EndTitle> $text = preg_replace_callback("/(<\s*span[^>]*class\s*=\s*[\"']campsite_subhead[\"'][^>]*>|<\s*span|<\s*\/\s*span\s*>)/i", array('ArticleData', "TransformSubheads"), $p_value); // Replace <a href="campsite_internal_link?IdPublication=1&..." ...> ... </a> // with <!** Link Internal IdPublication=1&...> ... <!** EndLink> $text = preg_replace_callback("/(<\s*a\s*(((href\s*=\s*[\"'](\\/campsite\\/)?campsite_internal_link[?][\w&=;]*[\"'])|(\w+\s*=\s*['\"][_\w]*['\"]))+[\s]*)*[\s\w\"']*>)|(<\s*\/a\s*>)/i", array('ArticleData', "TransformInternalLinks"), $text); // Replace <img id=".." src=".." alt=".." title=".." align=".."> // with <!** Image [image_template_id] align=".." alt=".." sub=".."> $idAttr = "(id\s*=\s*\"[^\"]*\")"; $srcAttr = "(src\s*=\s*\"[^\"]*\")"; $altAttr = "(alt\s*=\s*\"[^\"]*\")"; $subAttr = "(title\s*=\s*\"[^\"]*\")"; $alignAttr = "(align\s*=\s*\"[^\"]*\")"; $widthAttr = "(width\s*=\s*\"[^\"]*\")"; $heightAttr = "(height\s*=\s*\"[^\"]*\")"; $otherAttr = "(\w+\s*=\s*\"[^\"]*\")*"; $pattern = "/<\s*img\s*(($idAttr|$srcAttr|$altAttr|$subAttr|$alignAttr|$widthAttr|$heightAttr|$otherAttr)\s*)*\/>/i"; $p_value = preg_replace_callback($pattern, array($this, "transformImageTags"), $text); } if ($articleField->getType() == ArticleTypeField::TYPE_SWITCH) { return parent::setProperty($p_dbColumnName, (int)($p_value == 'on'), $p_commit); } return parent::setProperty($p_dbColumnName, $p_value, $p_commit, $p_isSql); }
public function setProperty($p_name, $p_value) { switch ($p_name) { case 'question': case 'answer': if ($this->getProperty($p_name) == '') { parent::setProperty($p_name.'_date', date('Y-m-d H:i:s')); } break; } $return = parent::setProperty($p_name, $p_value); $CampCache = CampCache::singleton(); $CampCache->clear('user'); return $return; }
/** * Set the given column name to the given value. * The object's internal variable will also be updated. * If the value hasn't changed, the database will not be updated. * * Note: Returns false when setting the fields node_left and node_right. * We don't want to allow direct update of these fields. * * Note: You cannot set $p_commit to FALSE and $p_isSql to TRUE * at the same time. * * @param string $p_dbColumnName * The name of the column that is to be updated. * * @param string $p_value * The value to set. * * @param boolean $p_commit * If set to true, the value will be written to the database immediately. * If set to false, the value will not be written to the database. * Default is true. * * @param boolean $p_isSql * Set this to TRUE if p_value consists of SQL commands. * There is no way to know what the result of the command is, * so we will need to refetch the value from the database in * order to update the internal variable's value. * * @return boolean * TRUE on success, FALSE on error. */ public function setProperty($p_dbColumnName, $p_value, $p_commit = true, $p_isSql = false) { if ($p_dbColumnName == 'node_left' || $p_dbColumnName == 'node_right') { return false; } return parent::setProperty($p_dbColumnName, $p_value, $p_commit, $p_isSql); }
function setProperty($p_name, $p_value) { if ($p_name == 'topics') { $return = $this->setTopics($p_value); $CampCache = CampCache::singleton(); $CampCache->clear('user'); return $return; } /* if ($p_name == 'admin_status') { switch ($p_value) { case 'online': case 'moderated': case 'readonly': parent::setProperty('date', date('Y-m-d H:i:s')); break; case 'offline': case 'pending': parent::setProperty('date', null); break; } } */ $result = parent::setProperty($p_name, $p_value); if ($p_name == 'status' || $p_name == 'admin_status') { require_once 'Blog.php'; Blog::TriggerCounters($this->getProperty('fk_blog_id')); } $CampCache = CampCache::singleton(); $CampCache->clear('user'); return $result; }
/** * @param int $p_value * @return boolean */ public function setAuthorId($p_value, $p_commit = true) { return parent::setProperty('fk_author_id', $p_value, $p_commit); } // fn setAuthorId
public function setProperty($p_dbColumnName, $p_value, $p_commit = true, $p_isSql = false) { if (!in_array($p_dbColumnName, $this->m_columnNames)) { return false; } $articleField = new ArticleTypeField($this->m_articleTypeName, substr($p_dbColumnName, 1)); if ($articleField->getType() == ArticleTypeField::TYPE_BODY) { // Replace <span class="subhead"> ... </span> with <!** Title> ... <!** EndTitle> $text = preg_replace_callback("/(<\\s*span[^>]*class\\s*=\\s*[\"']campsite_subhead[\"'][^>]*>|<\\s*span|<\\s*\\/\\s*span\\s*>)/i", array('ArticleData', "TransformSubheads"), $p_value); // Replace <a href="campsite_internal_link?IdPublication=1&..." ...> ... </a> // with <!** Link Internal IdPublication=1&...> ... <!** EndLink> $text = preg_replace_callback("/(<\\s*a\\s*(((href\\s*=\\s*[\"'](\\/campsite\\/)?campsite_internal_link[?][\\w&=;]*[\"'])|(\\w+\\s*=\\s*['\"][_\\w]*['\"]))+[\\s]*)*[\\s\\w\"']*>)|(<\\s*\\/a\\s*>)/i", array('ArticleData', "TransformInternalLinks"), $text); // Replace <img id=".." src=".." alt=".." title=".." align=".."> // with <!** Image [image_template_id] align=".." alt=".." sub=".."> $idAttr = "(id\\s*=\\s*\"[^\"]*\")"; $srcAttr = "(src\\s*=\\s*\"[^\"]*\")"; $altAttr = "(alt\\s*=\\s*\"[^\"]*\")"; $subAttr = "(title\\s*=\\s*\"[^\"]*\")"; $alignAttr = "(align\\s*=\\s*\"[^\"]*\")"; $widthAttr = "(width\\s*=\\s*\"[^\"]*\")"; $heightAttr = "(height\\s*=\\s*\"[^\"]*\")"; $otherAttr = "(\\w+\\s*=\\s*\"[^\"]*\")*"; $pattern = "/<\\s*img\\s*{$idAttr}\\s*(({$srcAttr}|{$altAttr}|{$subAttr}|{$alignAttr}|{$widthAttr}|{$heightAttr}|{$otherAttr})\\s*)*\\/>/i"; $p_value = preg_replace_callback($pattern, array($this, "transformImageTags"), $text); // Replace snippets div holder with snippets tag // Replace <div data-snippet-id="$1" class="camp_snippet">Snippet $1</div> // with <-- Snippet 1 --> $pattern = "/<div\\s*class=\"camp_snippet\"\\s*(?:data-snippet-id=\"([\\d*])\")>([\\w*]+)* ([\\d*]+)<\\/div>/i"; $p_value = preg_replace($pattern, "<-- Snippet \$1 -->", $p_value); } if ($articleField->getType() == ArticleTypeField::TYPE_SWITCH) { if (is_string($p_value)) { return parent::setProperty($p_dbColumnName, (int) ($p_value == 'on'), $p_commit); } elseif (is_int($p_value)) { return parent::setProperty($p_dbColumnName, $p_value, $p_commit); } } return parent::setProperty($p_dbColumnName, $p_value, $p_commit, $p_isSql); }
/** * If we modify the admin status, * the publish date is modified too. * * @param string $p_name * @param sring $p_value */ function setProperty($p_name, $p_value) { /* if ($p_name == 'admin_status') { switch ($p_value) { case 'online': case 'moderated': case 'readonly': parent::setProperty('date', date('Y-m-d H:i:s')); break; case 'offline': case 'pending': parent::setProperty('date', null); break; } } */ if ($p_name == 'topics') { $return = $this->setTopics($p_value); $CampCache = CampCache::singleton(); $CampCache->clear('user'); return $return; } if ($p_name == 'fk_language_id') { $this->onSetLanguage($p_value); } $return = parent::setProperty($p_name, $p_value); $CampCache = CampCache::singleton(); $CampCache->clear('user'); return $return; }