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


PHP Mongo::close方法代碼示例

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


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

示例1: disconnect

 /**
  * Disconnect from MongoDB
  *
  * @returns null
  */
 public function disconnect()
 {
     if ($this->_connection) {
         $this->_connection->close();
     }
     $this->_db = $this->_connection = NULL;
 }
開發者ID:SerdarSanri,項目名稱:mongor,代碼行數:12,代碼來源:mongodb.php

示例2: close

 /**
  * Closes the currently active Mongo connection.
  * It does nothing if the connection is already closed.
  * @since v1.0
  */
 protected function close()
 {
     if ($this->_mongoConnection !== null) {
         $this->_mongoConnection->close();
         $this->_mongoConnection = null;
         Yii::trace('Closing MongoDB connection', 'ext.MongoDb.EMongoDB');
     }
 }
開發者ID:phiphi1992,項目名稱:alongaydep,代碼行數:13,代碼來源:EMongoDB.php

示例3: disconnect

 /**
  * Disconnect from a mongo database.
  *
  * @return boolean disconnect result
  */
 public function disconnect()
 {
     if ($this->connection->close()) {
         $this->connected = false;
         return true;
     }
     return false;
 }
開發者ID:acim,項目名稱:monga,代碼行數:13,代碼來源:Connection.php

示例4: testClose

 public function testClose()
 {
     $this->object = new Mongo();
     $this->assertTrue($this->object->connected);
     $this->object->close();
     $this->assertFalse($this->object->connected);
     $this->object->close();
     $this->assertFalse($this->object->connected);
 }
開發者ID:rosarion,項目名稱:mongo-php-driver,代碼行數:9,代碼來源:MongoTest.php

示例5: disconnect

 /**
  * Disconnect from MongoDB
  *
  * @return null
  */
 public function disconnect()
 {
     if ($this->_connection) {
         try {
             $this->_connection->close();
         } catch (\Exception $e) {
         }
     }
     $this->_db = $this->_connection = null;
 }
開發者ID:agolomazov,項目名稱:mongodm,代碼行數:15,代碼來源:MongoDB.php

示例6: save

 public function save()
 {
     $conn = new Mongo('localhost');
     $db = $conn->users;
     $collection = $db->items;
     $collection->save($this->auth);
     $this->obj->bid->userAuthData();
     $this->result = 'ok';
     $conn->close();
 }
開發者ID:riconegri,項目名稱:Youtube---Php-com-Mongo,代碼行數:10,代碼來源:rpc.php

示例7: cse

function cse()
{
    // Open the log file to which to write outputs
    $fp = fopen('test.log', 'at');
    // Get all http headers in the received message
    $headers = getallheaders();
    // Get the posted message body
    // NOTE: The message body is currently in Avro binary form
    $post_data = file_get_contents("php://input");
    // Get the URI of the Avro schema on the OCL server that adheres to the /cse/offer/create contract
    $schema_uri = $headers['X-XC-SCHEMA-URI'];
    // Get the contents of the Avro schema identified by the URI retrieved above
    $content = file_get_contents($schema_uri);
    // Parse the CSE Avro schema and place results in an AvroSchema object
    $schema = AvroSchema::parse($content);
    //fwrite($fp, $schema);
    //fwrite($fp, "\n");
    // Use Avro to decode and deserialize the binary-encoded message body.
    // The result is the plain text version of the message body
    // The message sender used Avro to binary-encode the text version of the message body before sending the message.
    // Create an AvroIODatumReader object for the supplied AvroSchema.
    // An AvroIODatumReader object handles schema-specific reading of data from the decoder and
    // ensures that each datum read is consistent with the reader's schema.
    $datum_reader = new AvroIODatumReader($schema);
    // Create an AvroStringIO object and assign it the encoded message body
    $read_io = new AvroStringIO($post_data);
    // Create an AvroIOBinaryDecoder object and assign it the $read_io object
    $decoder = new AvroIOBinaryDecoder($read_io);
    // Decode and deserialize the data using the CSE schema and the supplied decoder
    // The data is retrieved from the AvroStringIO object $read_io created above
    // Upon return, $message contains the plain text version of the X.commerce message sent by the publisher
    $message = $datum_reader->read($decoder);
    //fwrite($fp, $post_data);
    fwrite($fp, "\n");
    //fwrite($fp, print_r($message, true));
    fwrite($fp, print_r($headers, true));
    // Connect to the Mongo server running on your machine
    // NOTE: you must start the Mongo server prior to running this web application
    $conn = new Mongo('localhost');
    // Access the cse_data database
    // If this database does not exist, Mongo creates it
    $db = $conn->cse_data;
    // Access the google collection
    // If this collection does not exist, Mongo creates it
    $collection = $db->google;
    // Insert a new document into the google collection
    $item = $message["products"];
    $collection->insert($item);
    // Write to log file
    fwrite($fp, print_r($item, true));
    fwrite($fp, "Inserted document with ID: " . $item['_id']);
    fclose($fp);
    // Disconnect from the MongoDB server
    $conn->close();
}
開發者ID:rfmcpherson,項目名稱:Sample-capabilities,代碼行數:55,代碼來源:index.php

示例8: close

 /**
  * Closes the connection to the logging database
  */
 public function close()
 {
     if ($this->closed != true) {
         $this->collection = null;
         if ($this->connection !== null) {
             $this->connection->close();
             $this->connection = null;
         }
         $this->closed = true;
     }
 }
開發者ID:alexandreannic,項目名稱:android-holo-colors,代碼行數:14,代碼來源:LoggerAppenderMongoDB.php

示例9: modifyDataFrom

 /**
  * modify the information of one student
  */
 public static function modifyDataFrom($collection_name, $data, $id, $id_value)
 {
     try {
         $connection = new Mongo();
         $db = $connection->selectDB('nhanviendb');
         $collection = $db->{$collection_name};
         $collection->update(array($id => $id_value), array('$set' => array("MaNV" => $data["MaNV"], "HoTen" => $data["HoTen"], "NgaySinh" => $data["NgaySinh"], "DiaChi" => $data["DiaChi"], "Phai" => $data["Phai"], "Luong" => $data["Luong"], "Phong" => $data["Phong"])));
         $connection->close();
     } catch (MongoConnectionException $e) {
         die('Error connecting to MongoDB server');
     } catch (MongoException $e) {
         die('Error : ' . $e->getMessage());
     }
 }
開發者ID:nguyenminhthong27,項目名稱:academic-term2-2012-distributed-application-group-21,代碼行數:17,代碼來源:MongoDatabase.php

示例10: index

 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function index()
 {
     try {
         $mongo = new Mongo();
         //create a connection to MongoDB
         $databases = $mongo->listDBs();
         //List all databases
         echo '<pre>';
         print_r($databases);
         $mongo->close();
     } catch (MongoConnectionException $e) {
         //handle connection error
         die($e->getMessage());
     }
     return view('welcome');
 }
開發者ID:ranjita-unified,項目名稱:laravel,代碼行數:21,代碼來源:WelcomeController.php

示例11: getTableWithCondition

 /**
  * get  table with condition
  * @param string $restaurant local restaurant or the other
  * @param string $areaID area
  * @param string $status table status
  * @param datetime $from php datetime, formatted with standard ("2010-01-15 00:00:00")
  * @param datetime $to php datetime, formatted with standard ("2010-01-15 00:00:00")
  * @return array table + info
  */
 public function getTableWithCondition($restaurant = null, $areaID = null, $status = null, $from, $to)
 {
     try {
         // create connection
         $connection = new Mongo(TableDAO::Host);
         $db = $connection->selectDB(TableDAO::DbName);
         // step 1 : get tables which's booked between (from, to)
         $collectionName = "ChiTietDatCho";
         $collection = $db->{$collectionName};
         $condition = $this->createConditionToGetTable(null, null, null, $from, $to);
         $result = $collection->find($condition, array("MaBanAn" => 1, "_id" => 0));
         $bookedTables = array();
         foreach ($result as $idx => $document) {
             foreach ($document as $key => $value) {
                 $bookedTables[$idx] = $value;
             }
         }
         // step 2 : get all tables
         $collectionName = "BanAn";
         $collection = $db->{$collectionName};
         $result = $collection->find(array(), array("MaBanAn" => 1, "_id" => 0));
         $tables = array();
         foreach ($result as $idx => $document) {
             foreach ($document as $key => $value) {
                 $tables[$idx] = $value;
             }
         }
         // step 3 : except and get result
         $availTable = array_diff($tables, $bookedTables);
         // step 4 : get detail info of free-table
         $availTableDetails = array();
         foreach ($availTable as $idx => $val) {
             $availTableDetails[] = $this->getTableInfo($val);
         }
         $connection->close();
         return $availTableDetails;
     } catch (MongoConnectionException $e) {
         die('Error connecting to MongoDB server');
     } catch (MongoException $e) {
         die('Error: ' . $e->getMessage());
     }
 }
開發者ID:nguyenminhthong27,項目名稱:academic-term2-2012-distributed-application-group-21,代碼行數:51,代碼來源:TableDAO.php

示例12: loadUser

 public function loadUser($model = 'users', $options = array())
 {
     $_options = array('actions' => array('metodo' => array('type' => 'find', 'where' => array())));
     $options = Set::merge($_options, $options);
     try {
         $conn = new Mongo('localhost');
         $db = $conn->{$model};
         $collection = $db->{$model};
         foreach ($options['actions'] as $action) {
             $res[] = $collection->{$action['type']}($action['where']);
         }
         $conn->close();
         return $res;
         //$this->U->remove(array('email'=>'{'));
         //prMongo($this->U->find());
     } catch (MongoConnectionException $e) {
         die('Error connecting to MongoDB server');
     } catch (MongoException $e) {
         die('Error: ' . $e->getMessage());
     }
 }
開發者ID:riconegri,項目名稱:Youtube---Php-com-Mongo,代碼行數:21,代碼來源:Mongo.php

示例13: substr

$date = $_POST['date'];
// convert from american format to data format
$date1 = substr($date, 6, 4);
$date2 = substr($date, 0, 2);
$date3 = substr($date, 3, 2);
$date = $date1 . $date2 . $date3;
try {
    // open connection to LOCAL MongoDB server
    // $conn = new Mongo('localhost');
    // open connection to CLOUD MongoDB server
    $conn = new Mongo("mongodb://pintwister:pitboss1@dbh56.mongolab.com:27567/pianos");
    // access database
    $db = $conn->pianos;
    // access collection
    $collection = $db->mile;
    // define a new document with safe insert
    $item = array('userid' => $userid, 'ldate' => $date, 'start' => $fstart, 'end' => $fend, 'tot' => $ftot, 'expl' => $fexpl);
    $options = array("safe" => True);
    // insert the new document
    $collection->insert($item, $options);
    // disconnect from server
    $conn->close();
    header("location: mileage.php");
} catch (MongoConnectionException $e) {
    die('Error connecting to MongoDB server');
} catch (MongoException $e) {
    die('Error: ' . $e->getMessage());
}
?>

開發者ID:pintwister,項目名稱:pianos,代碼行數:29,代碼來源:addmile.php

示例14: array

$data = $collection->find()->limit(10)->skip(5);
foreach ($data as $key => $value) {
    // var_dump( $value ) ;
}
/* 排序條件查詢sort() */
$data = $collection->find()->limit(10)->sort(array('_id' => -1));
// $data = $data->snapshot() ; 					# 排序和snapshot() 查詢出對象不能使用foreach
foreach ($data as $key => $value) {
    // var_dump( $value ) ;
}
/* 指定查詢的列 fields() true 顯示 false 不顯示 */
$data = $collection->find()->limit(10)->fields(array('_id' => false));
// _id 列不顯示
// $data = $collection->find()->limit(10)->sort(array('_id' => -1 ))->fields(array('username'=> true)) ; # 隻顯示username(_id默認顯示)
foreach ($data as $key => $value) {
    // var_dump( $value ) ;
}
/**
 * *** 7.索引操作 ensureIndex() ^.^ --->
 * ensureIndex( array() , array( 'name' =>'索引名稱' ,' background' = true , 'unique' = true))
 * 詳見:http://www.php.net/manual/en/mongocollection.ensureindex.php
 */
$collection->ensureIndex(array(‘age’ => 1, ’type’ => -1));
// 表示降序 -1表示升序
$collection->ensureIndex(array(‘age’ => 1, ’type’ => -1), array(‘background’ => true));
// 索引的創建放在後台運行(默認是同步運行)
$collection->ensureIndex(array(‘age’ => 1, ’type’ => -1), array(‘unique’ => true));
// 該索引是唯一的
// *** 8.關閉連接 close() ^.^ --->
$connection->close();
開發者ID:gyhkevin,項目名稱:learnNote,代碼行數:30,代碼來源:mongodb.php

示例15: close

 /** @proxy */
 public function close()
 {
     $this->initialize();
     return $this->mongo->close();
 }
開發者ID:ud223,項目名稱:yj,代碼行數:6,代碼來源:Connection.php


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