略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Schema::getCollections

2024-12-22

Schema::getCollections

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

Schema::getCollectionsGet all schema collections

说明

public mysql_xdevapi\Schema::getCollections(): array

Fetch a list of collections for this schema.

参数

此函数没有参数。

返回值

Array of all collections in this schema, where each array element value is a Collection object with the collection name as the key.

范例

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

<?php
$session 
mysql_xdevapi\getSession("mysqlx://user:password@localhost");
$session->sql("DROP DATABASE IF EXISTS addressbook")->execute();
$session->sql("CREATE DATABASE addressbook")->execute();

$schema  $session->getSchema("addressbook");
$collect $schema->createCollection("people");
$collect->add('{"name": "Fred",  "age": 21, "job": "Construction"}')->execute();
$collect->add('{"name": "Wilma", "age": 23, "job": "Teacher"}')->execute();

$collections $schema->getCollections();
var_dump($collections);
?>

以上例程的输出类似于:

array(1) {
  ["people"]=>
  object(mysql_xdevapi\Collection)#4 (1) {
    ["name"]=>
    string(6) "people"
  }
}
add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

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

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