Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$title is deprecated in /home/www/dev/work/website/lvesu/class/controller/blog/php.php on line 28

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/php.manual.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
PHP - Manual: 获取集合实例 - 互联网笔记

略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: 获取集合实例

2025-05-19

获取集合实例

获取一个集合的语法与获取数据库时相同:

<?php
$connection 
= new MongoClient();
$db $connection->baz;

// select a collection:
$collection $db->foobar;

// or, directly selecting a database and collection:
$collection $connection->baz->foobar;
?>

一个集合相当于一张表。(如果你对关系型数据库比较熟悉)

参见

MongoCollection 类的文档中有对集合对象的详细说明。

add a note add a note

User Contributed Notes 1 note

up
0
jerome at chaman dot ca
4 years ago
If your collection uses dot notation, get it with MongoDB::selectCollection :

$colors = $db->selectCollection('my.colors');

官方地址:https://www.php.net/manual/en/mongo.tutorial.collection.php

冷却塔厂家 广告
中文GPT4.0无需注册 广告
北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3