當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Mongo::update方法代碼示例

本文整理匯總了PHP中Mongo::update方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mongo::update方法的具體用法?PHP Mongo::update怎麽用?PHP Mongo::update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mongo的用法示例。


在下文中一共展示了Mongo::update方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testSet

 public function testSet()
 {
     ini_set("mongo.cmd", "!");
     $this->object->save(array('name' => 'google.com'));
     $this->object->update(array(), array('!set' => array("name" => "yahoo.com")));
     $yahoo = $this->object->findOne();
     $this->assertEquals('yahoo.com', $yahoo['name']);
     ini_set("mongo.cmd", "#");
     $this->object->update(array(), array('#set' => array("name" => "askjeeves.com")));
     $jeeves = $this->object->findOne();
     $this->assertEquals('askjeeves.com', $jeeves['name']);
 }
開發者ID:rjonker,項目名稱:mongo-php-driver,代碼行數:12,代碼來源:CmdSymbolTest.php

示例2: update

 public function update($criteria, $newobj, array $options = array())
 {
     try {
         $options = array_merge($options, array('safe' => TRUE, 'multiple' => FALSE));
         return parent::update($criteria, $newobj, $options);
     } catch (MongoCursorException $e) {
         show_error("MongoDB update failed: {$e->getMessage()}", 500);
     }
 }
開發者ID:navruzm,項目名稱:navruz.net,代碼行數:9,代碼來源:Mongo_db.php

示例3: testUpdate

 public function testUpdate()
 {
     $old = (object) array("foo" => "bar", "x" => "y");
     $new = (object) array("foo" => "baz");
     $this->object->update((object) array("foo" => "bar"), $old, true);
     $obj = $this->object->findOne();
     $this->assertEquals($obj['foo'], 'bar');
     $this->assertEquals($obj['x'], 'y');
     $this->object->update($old, $new);
     $obj = $this->object->findOne();
     $this->assertEquals($obj['foo'], 'baz');
 }
開發者ID:redmeadowman,項目名稱:mongo-php-driver,代碼行數:12,代碼來源:MongoObjectsTest.php

示例4: __gc

 /**
  * Helper function called on gc for database sessions.
  *
  * @param integer $expiry Timestamp (defaults to current time)
  * @return boolean Success
  * @access private
  */
 public function __gc($expiry = null)
 {
     if (!$expiry) {
         $expiry = time();
     }
     // define the query
     $query = array('expiry' => array('$lt' => $expiry));
     // specify the update vars
     $update = array('$set' => array('active' => 0));
     // update options
     $options = array('multiple' => TRUE, 'safe' => TRUE, 'fsync' => TRUE);
     // update expired elements and set to inactive
     $this->_mongo->update($query, $update, $options);
     return true;
 }
開發者ID:radig,項目名稱:CakeMongoSession,代碼行數:22,代碼來源:cake_mongo_session.php


注:本文中的Mongo::update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。