DocResult::fetchAll

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

DocResult::fetchAll — 모든 행 가져오기


설명

public mysql_xdevapi\DocResult::fetchAll(): array

결과 집합에서 모든 결과를 가져옵니다.


매개변수

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


반환 값

쿼리의 모든 결과가 포함된 숫자 배열입니다. 각 결과는 연관 배열입니다. 행이 없으면 빈 배열이 반환됩니다.


Examples

예제 #1 mysql_xdevapi\DocResult::fetchAll() 예제

                  
<?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();
$create->add('{"name": "Reginald", "age": 42, "job": "Butler"}')->execute();

// ...

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

// Yields a DocResult object
$result = $collection
  ->find('job like :job and age > :age')
  ->bind(['job' => 'Butler', 'age' => 16])
  ->sort('age desc')
  ->execute();

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

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

array(2) {

  [0]=>
  array(4) {
    ["_id"]=>
    string(28) "00005b6b53610000000000000123"
    ["age"]=>
    int(42)
    ["job"]=>
    string(6) "Butler"
    ["name"]=>
    string(8) "Reginald"
  }

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

}