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


PHP DatabaseBase::insert方法代码示例

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


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

示例1: addCoreDBData

 private function addCoreDBData()
 {
     # disabled for performance
     #$this->tablesUsed[] = 'page';
     #$this->tablesUsed[] = 'revision';
     if ($this->db->getType() == 'oracle') {
         # Insert 0 user to prevent FK violations
         # Anonymous user
         $this->db->insert('user', array('user_id' => 0, 'user_name' => 'Anonymous'), __METHOD__, array('IGNORE'));
         # Insert 0 page to prevent FK violations
         # Blank page
         $this->db->insert('page', array('page_id' => 0, 'page_namespace' => 0, 'page_title' => ' ', 'page_restrictions' => NULL, 'page_counter' => 0, 'page_is_redirect' => 0, 'page_is_new' => 0, 'page_random' => 0, 'page_touched' => $this->db->timestamp(), 'page_latest' => 0, 'page_len' => 0), __METHOD__, array('IGNORE'));
     }
     User::resetIdByNameCache();
     //Make sysop user
     $user = User::newFromName('UTSysop');
     if ($user->idForName() == 0) {
         $user->addToDatabase();
         $user->setPassword('UTSysopPassword');
         $user->addGroup('sysop');
         $user->addGroup('bureaucrat');
         $user->saveSettings();
     }
     //Make 1 page with 1 revision
     $page = WikiPage::factory(Title::newFromText('UTPage'));
     if (!$page->getId() == 0) {
         $page->doEdit('UTContent', 'UTPageSummary', EDIT_NEW, false, User::newFromName('UTSysop'));
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:29,代码来源:MediaWikiTestCase.php

示例2: batchInsert

 /**
  * Batch insert rows
  *
  * @param array $info Array with array members that have 'name' and 'wiki' keys
  */
 public function batchInsert(array $info)
 {
     $rows = array();
     foreach ($info as $row) {
         $rows[] = array('utr_name' => $row['name'], 'utr_wiki' => $row['wiki']);
     }
     $this->db->insert('users_to_rename', $rows, __METHOD__, array('IGNORE'));
 }
开发者ID:NDKilla,项目名称:mediawiki-extensions-CentralAuth,代码行数:13,代码来源:UsersToRenameDatabaseUpdates.php

示例3: copyLocalImagelinks

 /**
  * Copy local links to global table
  *
  * @param $title Title Title of the file to copy entries from.
  */
 public function copyLocalImagelinks($title)
 {
     global $wgContLang;
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select(array('imagelinks', 'page'), array('il_to', 'page_id', 'page_namespace', 'page_title'), array('il_from = page_id', 'il_to' => $title->getDBkey()), __METHOD__);
     $insert = array();
     foreach ($res as $row) {
         $insert[] = array('gil_wiki' => $this->interwiki, 'gil_page' => $row->page_id, 'gil_page_namespace_id' => $row->page_namespace, 'gil_page_namespace' => $wgContLang->getNsText($row->page_namespace), 'gil_page_title' => $row->page_title, 'gil_to' => $row->il_to);
     }
     $this->db->insert('globalimagelinks', $insert, __METHOD__, array('IGNORE'));
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:16,代码来源:GlobalUsage_body.php

示例4: copyExactMatch

 function copyExactMatch($srcTable, $dstTable, $copyPos)
 {
     $numRowsCopied = 0;
     $srcRes = $this->dbw->select($srcTable, '*', array('log_timestamp' => $copyPos), __METHOD__);
     $dstRes = $this->dbw->select($dstTable, '*', array('log_timestamp' => $copyPos), __METHOD__);
     if ($srcRes->numRows()) {
         $srcRow = $srcRes->fetchObject();
         $srcFields = array_keys((array) $srcRow);
         $srcRes->seek(0);
         $dstRowsSeen = array();
         # Make a hashtable of rows that already exist in the destination
         foreach ($dstRes as $dstRow) {
             $reducedDstRow = array();
             foreach ($srcFields as $field) {
                 $reducedDstRow[$field] = $dstRow->{$field};
             }
             $hash = md5(serialize($reducedDstRow));
             $dstRowsSeen[$hash] = true;
         }
         # Copy all the source rows that aren't already in the destination
         foreach ($srcRes as $srcRow) {
             $hash = md5(serialize((array) $srcRow));
             if (!isset($dstRowsSeen[$hash])) {
                 $this->dbw->insert($dstTable, (array) $srcRow, __METHOD__);
                 $numRowsCopied++;
             }
         }
     }
     return $numRowsCopied;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:30,代码来源:upgradeLogging.php

示例5: addCoreDBData

 private function addCoreDBData()
 {
     if ($this->db->getType() == 'oracle') {
         # Insert 0 user to prevent FK violations
         # Anonymous user
         if (!$this->db->selectField('user', '1', ['user_id' => 0])) {
             $this->db->insert('user', ['user_id' => 0, 'user_name' => 'Anonymous'], __METHOD__, ['IGNORE']);
         }
         # Insert 0 page to prevent FK violations
         # Blank page
         if (!$this->db->selectField('page', '1', ['page_id' => 0])) {
             $this->db->insert('page', ['page_id' => 0, 'page_namespace' => 0, 'page_title' => ' ', 'page_restrictions' => null, 'page_is_redirect' => 0, 'page_is_new' => 0, 'page_random' => 0, 'page_touched' => $this->db->timestamp(), 'page_latest' => 0, 'page_len' => 0], __METHOD__, ['IGNORE']);
         }
     }
     User::resetIdByNameCache();
     // Make sysop user
     $user = static::getTestSysop()->getUser();
     // Make 1 page with 1 revision
     $page = WikiPage::factory(Title::newFromText('UTPage'));
     if ($page->getId() == 0) {
         $page->doEditContent(new WikitextContent('UTContent'), 'UTPageSummary', EDIT_NEW, false, $user);
         // doEditContent() probably started the session via
         // User::loadFromSession(). Close it now.
         if (session_id() !== '') {
             session_write_close();
             session_id('');
         }
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:29,代码来源:MediaWikiTestCase.php

示例6: convertOptionBatch

 /**
  * @param ResultWrapper $res
  * @param DatabaseBase $dbw
  * @return null|int
  */
 function convertOptionBatch($res, $dbw)
 {
     $id = null;
     foreach ($res as $row) {
         $this->mConversionCount++;
         $insertRows = array();
         foreach (explode("\n", $row->user_options) as $s) {
             $m = array();
             if (!preg_match("/^(.[^=]*)=(.*)\$/", $s, $m)) {
                 continue;
             }
             // MW < 1.16 would save even default values. Filter them out
             // here (as in User) to avoid adding many unnecessary rows.
             $defaultOption = User::getDefaultOption($m[1]);
             if (is_null($defaultOption) || $m[2] != $defaultOption) {
                 $insertRows[] = array('up_user' => $row->user_id, 'up_property' => $m[1], 'up_value' => $m[2]);
             }
         }
         if (count($insertRows)) {
             $dbw->insert('user_properties', $insertRows, __METHOD__, array('IGNORE'));
         }
         $dbw->update('user', array('user_options' => ''), array('user_id' => $row->user_id), __METHOD__);
         $id = $row->user_id;
     }
     return $id;
 }
开发者ID:kolzchut,项目名称:mediawiki-molsa-new,代码行数:31,代码来源:convertUserOptions.php

示例7: populateInterwikiTable

 /**
  * Common function for databases that don't understand the MySQLish syntax of interwiki.sql.
  *
  * @return Status
  */
 public function populateInterwikiTable()
 {
     $status = $this->getConnection();
     if (!$status->isOK()) {
         return $status;
     }
     $this->db->selectDB($this->getVar('wgDBname'));
     if ($this->db->selectRow('interwiki', '*', array(), __METHOD__)) {
         $status->warning('config-install-interwiki-exists');
         return $status;
     }
     global $IP;
     wfSuppressWarnings();
     $rows = file("{$IP}/maintenance/interwiki.list", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
     wfRestoreWarnings();
     $interwikis = array();
     if (!$rows) {
         return Status::newFatal('config-install-interwiki-list');
     }
     foreach ($rows as $row) {
         $row = preg_replace('/^\\s*([^#]*?)\\s*(#.*)?$/', '\\1', $row);
         // strip comments - whee
         if ($row == "") {
             continue;
         }
         $row .= "||";
         $interwikis[] = array_combine(array('iw_prefix', 'iw_url', 'iw_local', 'iw_api', 'iw_wikiid'), explode('|', $row));
     }
     $this->db->insert('interwiki', $interwikis, __METHOD__);
     return Status::newGood();
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:36,代码来源:DatabaseInstaller.php

示例8: addCoreDBData

 private function addCoreDBData()
 {
     if ($this->db->getType() == 'oracle') {
         # Insert 0 user to prevent FK violations
         # Anonymous user
         $this->db->insert('user', array('user_id' => 0, 'user_name' => 'Anonymous'), __METHOD__, array('IGNORE'));
         # Insert 0 page to prevent FK violations
         # Blank page
         $this->db->insert('page', array('page_id' => 0, 'page_namespace' => 0, 'page_title' => ' ', 'page_restrictions' => null, 'page_is_redirect' => 0, 'page_is_new' => 0, 'page_random' => 0, 'page_touched' => $this->db->timestamp(), 'page_latest' => 0, 'page_len' => 0), __METHOD__, array('IGNORE'));
     }
     User::resetIdByNameCache();
     // Make sysop user
     $user = User::newFromName('UTSysop');
     if ($user->idForName() == 0) {
         $user->addToDatabase();
         TestUser::setPasswordForUser($user, 'UTSysopPassword');
     }
     // Always set groups, because $this->resetDB() wipes them out
     $user->addGroup('sysop');
     $user->addGroup('bureaucrat');
     // Make 1 page with 1 revision
     $page = WikiPage::factory(Title::newFromText('UTPage'));
     if ($page->getId() == 0) {
         $page->doEditContent(new WikitextContent('UTContent'), 'UTPageSummary', EDIT_NEW, false, $user);
         // doEditContent() probably started the session via
         // User::loadFromSession(). Close it now.
         if (session_id() !== '') {
             session_write_close();
             session_id('');
         }
     }
 }
开发者ID:admonkey,项目名称:mediawiki,代码行数:32,代码来源:MediaWikiTestCase.php

示例9: setAppliedUpdates

 protected function setAppliedUpdates($version, $updates = array())
 {
     if (!$this->canUseNewUpdatelog()) {
         return;
     }
     $key = "updatelist-{$version}-" . time();
     $this->db->insert('updatelog', array('ul_key' => $key, 'ul_value' => serialize($updates)), __METHOD__);
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:8,代码来源:DatabaseUpdater.php

示例10: insertData

 /**
  * @param DatabaseBase $dbw
  * @return void
  */
 private function insertData($dbw)
 {
     $range = range(0, 1024);
     $data = array();
     foreach ($range as $r) {
         $data[] = array('text' => $r);
     }
     $dbw->insert('test', $data, __METHOD__);
 }
开发者ID:kolzchut,项目名称:mediawiki-molsa-new,代码行数:13,代码来源:bench_delete_truncate.php

示例11: insertUpdateRow

	/**
	 * Helper function: Add a key to the updatelog table
	 * Obviously, only use this for updates that occur after the updatelog table was
	 * created!
	 * @param string $key Name of key to insert
	 * @param string $val [optional] value to insert along with the key
	 */
	public function insertUpdateRow( $key, $val = null ) {
		$this->db->clearFlag( DBO_DDLMODE );
		$values = array( 'ul_key' => $key );
		if ( $val && $this->canUseNewUpdatelog() ) {
			$values['ul_value'] = $val;
		}
		$this->db->insert( 'updatelog', $values, __METHOD__, 'IGNORE' );
		$this->db->setFlag( DBO_DDLMODE );
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:16,代码来源:DatabaseUpdater.php

示例12: insertUsageCount

 /**
  * @see PropertyStatisticsStore::insertUsageCount
  *
  * @since 1.9
  *
  * @param integer $propertyId
  * @param integer $value
  *
  * @return boolean Success indicator
  * @throws MWException
  */
 public function insertUsageCount($propertyId, $value)
 {
     if (!is_int($value) || $value < 0) {
         throw new MWException('The value to add must be a positive integer');
     }
     if (!is_int($propertyId) || $propertyId <= 0) {
         throw new MWException('The property id to add must be a positive integer');
     }
     return $this->dbConnection->insert($this->table, array('usage_count' => $value, 'p_id' => $propertyId), __METHOD__);
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:21,代码来源:PropertyStatisticsTable.php

示例13: initDB

 private function initDB()
 {
     global $wgDBprefix;
     if ($wgDBprefix === $this->dbPrefix()) {
         throw new MWException('Cannot run unit tests, the database prefix is already "unittest_"');
     }
     $dbClone = new CloneDatabase($this->db, $this->listTables(), $this->dbPrefix());
     $dbClone->useTemporaryTables($this->useTemporaryTables);
     $dbClone->cloneTableStructure();
     if ($this->db->getType() == 'oracle') {
         $this->db->query('BEGIN FILL_WIKI_INFO; END;');
         # Insert 0 user to prevent FK violations
         # Anonymous user
         $this->db->insert('user', array('user_id' => 0, 'user_name' => 'Anonymous'));
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:16,代码来源:MediaWikiTestCase.php

示例14: tryInsertWiki

 function tryInsertWiki(DatabaseBase $db, $wikiId)
 {
     if (is_string($wikiId)) {
         $w = WikiFactory::UrlToID($wikiId);
         if ($w == null) {
             throw new Exception("Can't resolve " . $wikiId);
         }
         $wikiId = $w;
     }
     $res = $db->select("webmaster_sitemaps", array('wiki_id'), array("wiki_id" => $wikiId), __METHOD__);
     if ($res->fetchRow()) {
         return false;
     }
     //echo "insert: " . $wikiId . "\n";
     if (!$db->insert("webmaster_sitemaps", array("wiki_id" => $wikiId, "user_id" => null))) {
         throw new Exception("can't insert wiki id = " . $wikiId);
     }
     return true;
 }
开发者ID:yusufchang,项目名称:app,代码行数:19,代码来源:initial_sync_account.php

示例15: insertOn

 /**
  * Insert a new empty page record for this article.
  * This *must* be followed up by creating a revision
  * and running $this->updateRevisionOn( ... );
  * or else the record will be left in a funky state.
  * Best if all done inside a transaction.
  *
  * @param DatabaseBase $dbw
  * @return int|bool The newly created page_id key; false if the title already existed
  */
 public function insertOn($dbw)
 {
     $page_id = $dbw->nextSequenceValue('page_page_id_seq');
     $dbw->insert('page', array('page_id' => $page_id, 'page_namespace' => $this->mTitle->getNamespace(), 'page_title' => $this->mTitle->getDBkey(), 'page_restrictions' => '', 'page_is_redirect' => 0, 'page_is_new' => 1, 'page_random' => wfRandom(), 'page_touched' => $dbw->timestamp(), 'page_latest' => 0, 'page_len' => 0), __METHOD__, 'IGNORE');
     $affected = $dbw->affectedRows();
     if ($affected) {
         $newid = $dbw->insertId();
         $this->mId = $newid;
         $this->mTitle->resetArticleID($newid);
         return $newid;
     } else {
         return false;
     }
 }
开发者ID:jongfeli,项目名称:mediawiki,代码行数:24,代码来源:WikiPage.php


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