当前位置: 首页>>代码示例>>PHP>>正文


PHP DatabaseBase::delete方法代码示例

本文整理汇总了PHP中DatabaseBase::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseBase::delete方法的具体用法?PHP DatabaseBase::delete怎么用?PHP DatabaseBase::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DatabaseBase的用法示例。


在下文中一共展示了DatabaseBase::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: removeBatch

 /**
  * Remove a batch of users
  *
  * @param DatabaseBase $dbw
  * @param int[] $batch list of user IDs to remove
  */
 private function removeBatch(DatabaseBase $dbw, array $batch)
 {
     $rows = 0;
     $dbw->begin(__METHOD__);
     // remove entries from user table
     $dbw->delete(self::USER_TABLE, ['user_id' => $batch], __METHOD__);
     $rows += $dbw->affectedRows();
     // remove entries from user_properties table
     $dbw->delete('user_properties', ['up_user' => $batch], __METHOD__);
     $rows += $dbw->affectedRows();
     $dbw->commit(__METHOD__);
     $this->info('Batch removed', ['batch' => count($batch), 'rows' => $rows]);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:RemoveUserBase.class.php

示例2: mergePage

 /**
  * Merge page histories
  *
  * @param integer $id The page_id
  * @param Title $newTitle The new title
  * @return bool
  */
 private function mergePage($row, Title $newTitle)
 {
     $id = $row->page_id;
     // Construct the WikiPage object we will need later, while the
     // page_id still exists. Note that this cannot use makeTitleSafe(),
     // we are deliberately constructing an invalid title.
     $sourceTitle = Title::makeTitle($row->page_namespace, $row->page_title);
     $sourceTitle->resetArticleID($id);
     $wikiPage = new WikiPage($sourceTitle);
     $wikiPage->loadPageData('fromdbmaster');
     $destId = $newTitle->getArticleId();
     $this->beginTransaction($this->db, __METHOD__);
     $this->db->update('revision', array('rev_page' => $destId), array('rev_page' => $id), __METHOD__);
     $this->db->delete('page', array('page_id' => $id), __METHOD__);
     /* Call LinksDeletionUpdate to delete outgoing links from the old title,
      * and update category counts.
      *
      * Calling external code with a fake broken Title is a fairly dubious
      * idea. It's necessary because it's quite a lot of code to duplicate,
      * but that also makes it fragile since it would be easy for someone to
      * accidentally introduce an assumption of title validity to the code we
      * are calling.
      */
     $update = new LinksDeletionUpdate($wikiPage);
     $update->doUpdate();
     $this->commitTransaction($this->db, __METHOD__);
     return true;
 }
开发者ID:admonkey,项目名称:mediawiki,代码行数:35,代码来源:namespaceDupes.php

示例3: deleteRevs

 /**
  * Delete one or more revisions from the database
  * Do this inside a transaction
  *
  * @param array $id Array of revision id values
  * @param DatabaseBase $dbw DatabaseBase class (needs to be a master)
  */
 private function deleteRevs($id, &$dbw)
 {
     if (!is_array($id)) {
         $id = array($id);
     }
     $dbw->delete('revision', array('rev_id' => $id), __METHOD__);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:14,代码来源:deleteOrphanedRevisions.php

示例4: resetDB

 /**
  * Empty all tables so they can be repopulated for tests
  */
 private function resetDB()
 {
     if ($this->db) {
         if ($this->db->getType() == 'oracle') {
             if (self::$useTemporaryTables) {
                 wfGetLB()->closeAll();
                 $this->db = wfGetDB(DB_MASTER);
             } else {
                 foreach ($this->tablesUsed as $tbl) {
                     if ($tbl == 'interwiki') {
                         continue;
                     }
                     $this->db->query('TRUNCATE TABLE ' . $this->db->tableName($tbl), __METHOD__);
                 }
             }
         } else {
             foreach ($this->tablesUsed as $tbl) {
                 if ($tbl == 'interwiki' || $tbl == 'user') {
                     continue;
                 }
                 $this->db->delete($tbl, '*', __METHOD__);
             }
         }
     }
 }
开发者ID:admonkey,项目名称:mediawiki,代码行数:28,代码来源:MediaWikiTestCase.php

示例5: purgeCache

 /**
  * Purge the objectcache table
  */
 protected function purgeCache()
 {
     # We can't guarantee that the user will be able to use TRUNCATE,
     # but we know that DELETE is available to us
     $this->output("Purging caches...");
     $this->db->delete('objectcache', '*', __METHOD__);
     $this->output("done.\n");
 }
开发者ID:laiello,项目名称:media-wiki-law,代码行数:11,代码来源:DatabaseUpdater.php

示例6: mergePage

 /**
  * Merge page histories
  *
  * @param integer $id The page_id
  * @param Title $newTitle The new title
  */
 private function mergePage($id, Title $newTitle)
 {
     $destId = $newTitle->getArticleId();
     $this->db->begin(__METHOD__);
     $this->db->update('revision', array('rev_page' => $destId), array('rev_page' => $id), __METHOD__);
     $this->db->delete('page', array('page_id' => $id), __METHOD__);
     // @fixme Need WikiPage::doDeleteUpdates() or similar to avoid orphan
     // rows in the links tables.
     $this->db->commit(__METHOD__);
     return true;
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:17,代码来源:namespaceDupes.php

示例7: resetDB

 /**
  * Empty all tables so they can be repopulated for tests
  */
 private function resetDB()
 {
     if ($this->db) {
         foreach ($this->listTables() as $tbl) {
             if ($tbl == 'interwiki' || $tbl == 'user') {
                 continue;
             }
             $this->db->delete($tbl, '*', __METHOD__);
         }
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:14,代码来源:MediaWikiTestCase.php

示例8: purgeCache

	/**
	 * Purge the objectcache table
	 */
	public function purgeCache() {
		global $wgLocalisationCacheConf;
		# We can't guarantee that the user will be able to use TRUNCATE,
		# but we know that DELETE is available to us
		$this->output( "Purging caches..." );
		$this->db->delete( 'objectcache', '*', __METHOD__ );
		if ( $wgLocalisationCacheConf['manualRecache'] ) {
			$this->rebuildLocalisationCache();
		}
		MessageBlobStore::clear();
		$this->output( "done.\n" );
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:15,代码来源:DatabaseUpdater.php

示例9: doTableCleanup

 /**
  * Perform a cleanup for a set of wikis
  *
  * @param DatabaseBase $db database handler
  * @param string $table name of table to clean up
  * @param string $wiki_id_column table column name to use when querying for wiki ID
  * @param Array $city_ids IDs of wikis to remove from the table
  */
 private function doTableCleanup(DatabaseBase $db, $table, array $city_ids, $wiki_id_column = 'wiki_id')
 {
     $start = microtime(true);
     $db->delete($table, [$wiki_id_column => $city_ids], __METHOD__);
     $rows = $db->affectedRows();
     // just in case MW decides to start a transaction automagically
     $db->commit(__METHOD__);
     Wikia\Logger\WikiaLogger::instance()->info(__METHOD__, ['table' => $table, 'cities' => join(', ', $city_ids), 'count' => count($city_ids), 'took' => round(microtime(true) - $start, 4), 'rows' => $rows]);
     $this->output(sprintf("%s: %s - removed %d rows\n", date('Y-m-d H:i:s'), $table, $rows));
     // throttle delete queries
     if ($rows > 0) {
         sleep(5);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:22,代码来源:eventsCleanup.php

示例10: delete

 public function delete($table, $conds, $fname = 'DatabaseOracle::delete')
 {
     global $wgContLang;
     if ($wgContLang != null && $conds != null && $conds != '*') {
         $conds2 = array();
         $conds = !is_array($conds) ? array($conds) : $conds;
         foreach ($conds as $col => $val) {
             $col_info = $this->fieldInfoMulti($table, $col);
             $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
             if ($col_type == 'CLOB') {
                 $conds2['TO_CHAR(' . $col . ')'] = $wgContLang->checkTitleEncoding($val);
             } else {
                 if (is_array($val)) {
                     $conds2[$col] = $val;
                     foreach ($conds2[$col] as &$val2) {
                         $val2 = $wgContLang->checkTitleEncoding($val2);
                     }
                 } else {
                     $conds2[$col] = $wgContLang->checkTitleEncoding($val);
                 }
             }
         }
         return parent::delete($table, $conds2, $fname);
     } else {
         return parent::delete($table, $conds, $fname);
     }
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:27,代码来源:DatabaseOracle.php

示例11: delete

 public function delete($table, $conds, $fname = __METHOD__)
 {
     $this->mScrollableCursor = false;
     try {
         parent::delete($table, $conds, $fname);
     } catch (Exception $e) {
         $this->mScrollableCursor = true;
         throw $e;
     }
     $this->mScrollableCursor = true;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:11,代码来源:DatabaseMssql.php

示例12: writePropertyTableRowUpdates

 /**
  * Update one property table by inserting or deleting rows, and compute
  * the changes that this entails for the property usage counts. The
  * given rows are inserted into the table if $insert is true; otherwise
  * they are deleted. The property usage counts are recorded in the
  * call-by-ref parameter $propertyUseIncrements.
  *
  * The method assumes that all of the given rows are about the same
  * subject. This is ensured by callers.
  *
  * @since 1.8
  * @param array $propertyUseIncrements
  * @param SMWSQLStore3Table $propertyTable
  * @param array $rows array of rows to insert/delete
  * @param boolean $insert
  * @param DatabaseBase $dbw used for writing
  */
 protected function writePropertyTableRowUpdates(array &$propertyUseIncrements, SMWSQLStore3Table $propertyTable, array $rows, $insert, DatabaseBase $dbw)
 {
     if (empty($rows)) {
         //print "Nothing to " . ( $insert ? 'insert' : 'delete' ) . " for table {$propertyTable->getName()}.\n"; //DEBUG
         return;
     }
     //print ( $insert ? 'Inserting ' : 'Deleting ' ) . count( $rows ) . " row(s) in table {$propertyTable->getName()}.\n"; //DEBUG
     //print var_export( $rows, true ) . "\n"; //DEBUG
     if (!$propertyTable->usesIdSubject()) {
         // does not occur, but let's be strict
         throw new InvalidArgumentException('Operation not supported for tables without subject IDs.');
     }
     if ($insert) {
         $dbw->insert($propertyTable->getName(), array_values($rows), "SMW::writePropertyTableRowUpdates-insert-{$propertyTable->getName()}");
     } else {
         $condition = '';
         // We build a condition that mentions s_id only once,
         // since it must be the same for all rows. This should
         // help the DBMS in selecting the rows (it would not be
         // easy for to detect that all tuples share one s_id).
         $sid = false;
         foreach ($rows as $row) {
             if ($sid === false) {
                 $sid = $row['s_id'];
                 // 's_id' exists for all tables with $propertyTable->usesIdSubject()
             }
             unset($row['s_id']);
             if ($condition != '') {
                 $condition .= ' OR ';
             }
             $condition .= '(' . $dbw->makeList($row, LIST_AND) . ')';
         }
         $condition = "s_id=" . $dbw->addQuotes($sid) . " AND ({$condition})";
         $dbw->delete($propertyTable->getName(), array($condition), "SMW::writePropertyTableRowUpdates-delete-{$propertyTable->getName()}");
     }
     if ($propertyTable->isFixedPropertyTable()) {
         $property = new SMWDIProperty($propertyTable->getFixedProperty());
         $pid = $this->store->smwIds->makeSMWPropertyID($property);
     }
     foreach ($rows as $row) {
         if (!$propertyTable->isFixedPropertyTable()) {
             $pid = $row['p_id'];
         }
         if (!array_key_exists($pid, $propertyUseIncrements)) {
             $propertyUseIncrements[$pid] = 0;
         }
         $propertyUseIncrements[$pid] += $insert ? 1 : -1;
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:66,代码来源:SMW_SQLStore3_Writers.php

示例13: deleteAll

 /**
  * @see PropertyStatisticsStore::deleteAll
  *
  * @since 1.9
  *
  * @return boolean Success indicator
  */
 public function deleteAll()
 {
     return $this->dbConnection->delete($this->table, '*', __METHOD__);
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:11,代码来源:PropertyStatisticsTable.php

示例14: acceptRequest_rollback

 protected function acceptRequest_rollback(DatabaseBase $dbw, $user_id, $acd_id)
 {
     $dbw->begin();
     # DELETE the user in case something caused a COMMIT already somewhere.
     if ($user_id) {
         $dbw->delete('user', array('user_id' => $user_id), __METHOD__);
         $dbw->delete('user_groups', array('ug_user' => $user_id), __METHOD__);
     }
     # DELETE the new account_credentials row likewise.
     if ($acd_id) {
         $dbw->delete('account_credentials', array('acd_id' => $acd_id), __METHOD__);
     }
     $dbw->commit();
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:14,代码来源:AccountConfirmSubmission.php

示例15: save

 /**
  * Save the user into a centralauth database
  * @param DatabaseBase $db
  */
 public function save(DatabaseBase $db)
 {
     // Setup local wiki user
     if ($this->createLocal) {
         $user = User::newFromName($this->username);
         if ($user->idForName() == 0) {
             $user->addToDatabase();
             $user->setPassword($this->password);
             $user->saveSettings();
         }
     }
     // Setup global user
     $row = array('gu_name' => $this->username, 'gu_id' => $this->guId, 'gu_password' => $this->passHash, 'gu_salt' => $this->salt, 'gu_auth_token' => $this->authToken, 'gu_locked' => $this->locked, 'gu_hidden' => $this->hidden, 'gu_registration' => $this->registration, 'gu_email' => $this->email, 'gu_email_authenticated' => $this->emailAuthenticated, 'gu_home_db' => $this->homeDb, 'gu_enabled' => $this->enabled, 'gu_enabled_method' => $this->enabledMethod);
     $db->insert('globaluser', $row, __METHOD__);
     // Attach global to local accounts
     $db->delete('localuser', array('lu_name' => $this->username), __METHOD__);
     if (count($this->wikis)) {
         $db->insert('localuser', $this->wikis, __METHOD__);
     }
 }
开发者ID:NDKilla,项目名称:mediawiki-extensions-CentralAuth,代码行数:24,代码来源:CentralAuthTestUser.php


注:本文中的DatabaseBase::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。