DocResult::getWarnings

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

DocResult::getWarnings — 마지막 작업에서 경고 가져오기


설명

public mysql_xdevapi\DocResult::getWarnings(): array

MySQL 서버의 마지막 작업에서 생성된 경고를 가져옵니다.


매개변수

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


반환 값

마지막 작업의 Warning 개체 배열입니다. 각 개체는 오류 'message', 오류 'level' 및 오류 'code'를 정의합니다. 오류가 없으면 빈 배열이 반환됩니다.


Examples

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

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

if (!$result->getWarningsCount()) {
    echo "There was an error:\n";
    print_r($result->getWarnings());
    exit;
}

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

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

There was an error:

Array
(
    [0] => mysql_xdevapi\Warning Object
        (
            [message] => Something bad and so on
            [level] => 2
            [code] => 1365
        )
    [1] => mysql_xdevapi\Warning Object
        (
            [message] => Something bad and so on
            [level] => 2
            [code] => 1365
        )
)