CollectionModify::set

(사용 가능한 버전 정보가 없으며 Git에만 있을 수 있음)

CollectionModify::set — 문서 속성 설정


설명

public mysql_xdevapi\CollectionModify::set(string $collection_field, string $expression_or_literal): mysql_xdevapi\CollectionModify

컬렉션의 문서에 대한 속성을 설정하거나 업데이트합니다.


매개변수

collection_field
설정할 항목의 문서 경로(이름)입니다.
expression_or_literal
설정할 값입니다.

반환 값

CollectionModify 개체입니다.


Examples

예제 #1 mysql_xdevapi\CollectionModify::set() 예제

                  
<?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 = :name")
  ->bind(['name' => 'Bernie'])
  ->set("name", "Bern")
  ->execute();

$result = $collection
  ->find()
  ->execute();

print_r($result->fetchAll());
?>
                  
                

위의 예는 다음과 유사한 결과를 출력합니다.

Array
(
    [0] => Array
        (
            [_id] => 00005b6b53610000000000000111
            [name] => Bern
            [traits] => Array
                (
                    [0] => Friend
                    [1] => Brother
                    [2] => Human
                )
        )
)