(沒有版本資訊,可能只存在於 Git 中)
CollectionModify::__construct — CollectionModify 建構函式
修改 (更新) 集合,並由 mysql_xdevapi\Collection::modify() 方法實例化。
此函式沒有參數。
範例 #1 mysql_xdevapi\CollectionModify::__construct() 範例
<?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");
$collection = $schema->createCollection("people");
$result = $collection
->add(
'{"name": "Bernie",
"traits": ["Friend", "Brother", "Human"]}')
->execute();
$collection
->modify("name in ('Bernie', 'Jane')")
->arrayAppend('traits', 'Happy')
->execute();
$result = $collection
->find()
->execute();
print_r($result->fetchAll());
?>
以上範例會輸出類似以下的內容:
Array ( [0] => Array ( [_id] => 00005b6b5361000000000000010c [name] => Bernie [traits] => Array ( [0] => Friend [1] => Brother [2] => Human [3] => Happy ) ) )