/** * Inserts the object into the database. * * @since 1.20 * @deprecated since 1.22 * * @param string|null $functionName * @param array|null $options * * @return boolean Success indicator */ protected function insert($functionName = null, array $options = null) { $dbw = $this->table->getWriteDbConnection(); $success = $dbw->insert($this->table->getName(), $this->getWriteValues(), is_null($functionName) ? __METHOD__ : $functionName, $options); // DatabaseBase::insert does not always return true for success as documented... $success = $success !== false; if ($success) { $this->setField('id', $dbw->insertId()); } $this->table->releaseConnection($dbw); return $success; }
/** * Constructs a cache key to use for caching the list of sites. * * This includes the concrete class name of the site list as well as a version identifier * for the list's serialization, to avoid problems when unserializing site lists serialized * by an older version, e.g. when reading from a cache. * * The cache key also includes information about where the sites were loaded from, e.g. * the name of a database table. * * @see SiteList::getSerialVersionId * * @return String The cache key. */ protected function getCacheKey() { wfProfileIn(__METHOD__); if ($this->cacheKey === null) { $type = 'SiteList#' . SiteList::getSerialVersionId(); $source = $this->sitesTable->getName(); if ($this->sitesTable->getTargetWiki() !== false) { $source = $this->sitesTable->getTargetWiki() . '.' . $source; } $this->cacheKey = wfMemcKey("{$source}/{$type}"); } wfProfileOut(__METHOD__); return $this->cacheKey; }
/** * Add an amount (can be negative) to the specified field (needs to be numeric). * TODO: most off this stuff makes more sense in the table class * * @since 1.20 * * @param string $field * @param integer $amount * * @return boolean Success indicator */ public function addToField($field, $amount) { if ($amount == 0) { return true; } if (!$this->hasIdField()) { return false; } $absoluteAmount = abs($amount); $isNegative = $amount < 0; $dbw = wfGetDB(DB_MASTER); $fullField = $this->table->getPrefixedField($field); $success = $dbw->update($this->table->getName(), array("{$fullField}={$fullField}" . ($isNegative ? '-' : '+') . $absoluteAmount), array($this->table->getPrefixedField('id') => $this->getId()), __METHOD__); if ($success && $this->hasField($field)) { $this->setField($field, $this->getField($field) + $amount); } return $success; }