略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Schema::getCollection

2025-02-27

Schema::getCollection

(No version information available, might only be in Git)

Schema::getCollectionGet collection from schema

说明

public mysql_xdevapi\Schema::getCollection(string $name): mysql_xdevapi\Collection

Get a collection from the schema.

参数

name

Collection name to retrieve.

返回值

The Collection object for the selected collection.

示例

示例 #1 mysql_xdevapi\Schema::getCollection() example

<?php
$session
= mysql_xdevapi\getSession("mysqlx://user:password@localhost");

$session->sql("DROP DATABASE IF EXISTS food")->execute();
$session->sql("CREATE DATABASE food")->execute();

$schema = $session->getSchema("food");
$schema->createCollection("trees");

// ...

$trees = $schema->getCollection("trees");

var_dump($trees);

以上示例的输出类似于:

object(mysql_xdevapi\Collection)#3 (1) {
  ["name"]=>
  string(5) "trees"
}
添加备注

用户贡献的备注

此页面尚无用户贡献的备注。

官方地址:https://www.php.net/manual/en/mysql-xdevapi-schema.getcollection.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3