票務系統使用的 php MongoDB framework
-
票務系統使用的 php MongoDB framework
本帖下載内容已隐藏,请登入以查看隐藏内容!Method 列表
/**
* 新增
*
* @param $collection
* @param $data
* @return MongoDB\Driver\WriteResult
*/
public function insert($collection, array $data, string $policy = null ) /**
* 查詢
*
* @param $collection
* @param $where
* @param $options
* @return MongoDB\Driver\Cursor
* @see http://php.net/manual/en/mongodb-driver-query.construct.php#refsect1-mongodb-driver-query.construct-examples]
*/
public function query($collection, $where, array $options = []) /**
* 分頁查詢
*
* @param $collection
* @param $where
* @param $page page number (from 1)
* @param $item item per page
* @param $options
* @return MongoDB\Driver\Cursor
*/
public function pageQuery($collection, $where, int $page = 1, int $item = 20, array $options = []) /**
* 查詢結果筆數
*
* @param string $db Database name
* @param string $collection Collection name
* @param array $where 過濾條件
* @return int 符合條件的資料筆數
*/
public function count($db, $collection, $where) /**
* 取得查詢結果第一筆
*
* @param string $collection "[db name].[collection name]"
* @param string $where 過濾條件
* @param array $options 其他設定
* @return stdClass 查詢結果數據
*/
public function getOne($collection, $where, array $options = []) /**
* 取得多筆數據, 如果數據量太大, 請改用 query() 返回 Cursor
* 避免記憶體使用過大
*
* @param string $collection "[db name].[collection name]"
* @param string $where 過濾條件
* @param array $options 其他設定
* @return array 查詢結果數據
*/
public function getList($collection, $where, array $options = []) /**
* 取得目前時間封裝成 BSON 格式
*
* @return \MongoDB\BSON\UTCDateTime 目前應用端的系統時間
*/
public function getNowDateTime() /**
* timestamp 轉 Bson 日期格式
*
* @param integer @sec timestamp
* @return \MongoDB\BSON\UTCDateTime 目前應用端的系統時間
*/
public function newDateTime($sec) /**
* 寫入操作
*
* @param $collection
* @param $bulk MongoDB\Driver\BulkWrite
* @return MongoDB\Driver\WriteResult
*/
public function bulkWrite($collection, MongoDB\Driver\BulkWrite $bulk, string $policy = null) /**
* 更新
*
* @param $collection
* @param $where
* @param $data
* @param $options
* @return MongoDB\Driver\WriteResult
*/
public function update($collection, $where, array $data, array $options = [], string $policy = null) /**
* 刪除
*
* @param $collection
* @param $where
* @param $options
* @return MongoDB\Driver\WriteResult
*/
public function delete($collection, $where, array $options = [], string $policy = null) /**
* 執行 MongoDB Command
*
* @param string $db Database Name
* @param array $cmd 執行的命令描述
* @return MongoDB\Driver\Cursor
*/
public function command($db, $cmd) /**
* 列出目前的資料庫清單
*
*/
public function cmdListDB() /**
* 取得指定 database 的 Collection 清單
*
* @param string $db database名稱
* @return array Collection 清單
*/
public function cmdListCol(string $db) /**
* ping 指令
*
* @return float 執行狀態
*/
public function cmdPing() /**
* 刪除資料庫
*
* @param string $db database名稱
* @return float 執行結果
*/
public function cmdDropDatabase(string $db) /**
* 服務器狀態
*
* @return array 服務器列表
*/
public function cmdServerStatus() /**
* 取得 GridFS 實體
*
* @param string $database 儲存 gridfs 的資料庫名稱
* @return \MongoGridFS GridFS 物件
*/
public function getGridFS(string $database = 'gridfs') /**
* getAutoIncrementId 取得自動遞增id
*
* @param string $name collection name
* @access public
* @return 遞增後之id
*/
public function getAutoIncrementId($name) /**
* 聚合操作
*
* @param string $db Database Name
* @param string $ollection Collection Name
* @param array $aggreate 聚合操作
* @return array 執行結果, stdClass 集合
*/
public function aggregate($db, $collection, $aggreate)使用範例:
include 'MongoClient.php';
$mc = new MongoClient("mongodb://localhost:27017/");
$ret= $mc->random('myDB','myCollection',['concertNo'=>'f3ab3705a0db0cb1'], 3);
print_r($ret);