<?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");
$create = $schema->createCollection("people");
$collection = $schema->getCollection("people");
// add() を使う場合
$result = $collection->add('{"name": "Wilma", "age": 23, "job": "Teacher"}')->execute();
// addOrReplaceOne() を使う場合
// 注意: ここでは、既知の _id 値を渡しています
$result = $collection->addOrReplaceOne('00005b6b53610000000000000056', '{"name": "Fred", "age": 21, "job": "Construction"}');
?>