当前位置: 首页>>代码示例>>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;未经允许,请勿转载。