Documentation Home
MySQL PHP API
Download this Manual
PDF (US Ltr) - 2.4Mb
PDF (A4) - 2.4Mb
HTML Download (TGZ) - 250.9Kb
HTML Download (Zip) - 258.4Kb


MySQL PHP API  /  ...  /  Schema::getCollections

5.26.7 Schema::getCollections

Copyright 1997-2019 the PHP Documentation Group.

  • Schema::getCollections

    Get all schema collections

Description

public array mysql_xdevapi\Schema::getCollections();

Fetch a list of collections for this schema.

Parameters

This function has no parameters.

Return Values

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

Examples

Example 5.105 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);
?>

The above example will output something similar to:


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