Schema::getCollectionAsTable

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

Schema::getCollectionAsTableコレクションをテーブルオブジェクトとして取得する

説明

public mysql_xdevapi\Schema::getCollectionAsTable(string $name): mysql_xdevapi\Table

コレクションをコレクションオブジェクトではなく、テーブルオブジェクトとして取得します。

パラメータ

name

テーブルオブジェクトとしてインスタンス化するためのコレクション名

戻り値

コレクションに対応するテーブルオブジェクトを返します。

例1 Schema::getCollectionAsTable の例

<?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();

$table      $schema->getCollectionAsTable("people");
$collection $schema->getCollection("people");

var_dump($table);
var_dump($collection);

上の例の出力は、 たとえば以下のようになります。

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

object(mysql_xdevapi\Collection)#5 (1) {
  ["name"]=>
  string(6) "people"
}
関連キーワード:  コレクション, オブジェクト, テーブル, 取得, xdevapi, getCollectionAsTable, string, Table, Git, 出力