CollectionFind::execute

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

CollectionFind::execute — 명령문 실행


설명

public mysql_xdevapi\CollectionFind::execute(): mysql_xdevapi\DocResult

찾기 작업을 실행합니다. 이 기능은 메서드 체인을 허용합니다.


매개변수

이 함수에는 매개변수가 없습니다.


반환 값

결과를 가져오거나 작업 상태를 쿼리하는 DocResult 개체입니다.


Examples

예제 #1 CollectionFind 예제

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

$create
  ->add('{"name": "Alfred", "age": 18, "job": "Butler"}')
  ->execute();

// ...

$collection = $schema->getCollection("people");

$result = $collection
  ->find('job like :job and age > :age')
  ->bind(['job' => 'Butler', 'age' => 16])
  ->execute();

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

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

array(1) {
  [0]=>
  array(4) {
    ["_id"]=>
    string(28) "00005b6b536100000000000000cf"
    ["age"]=>
    int(18)
    ["job"]=>
    string(6) "Butler"
    ["name"]=>
    string(6) "Alfred"
  }
}