Schema::existsInDatabase

データベースに存在するかをチェックする

説明

public bool mysql_xdevapi\Schema::existsInDatabase()

現在のオブジェクト(スキーマ、テーブル、コレクション、またはビュー)が、 スキーマオブジェクト内に存在しているかを調べます。

パラメータ

この関数にはパラメータはありません。

戻り値

スキーマ、コレクション、テーブル、またはビューがスキーマに存在していれば true そうでなければ false を返します。

例1 mysql_xdevapi\Schema::existsInDatabase の例

<?php
$session 
mysql_xdevapi\getSession("mysqlx://user:password@localhost");

$session->sql("DROP DATABASE IF EXISTS food")->execute();
$session->sql("CREATE DATABASE food")->execute();
$session->sql("CREATE TABLE food.fruit(name text, rating text)")->execute();

$schema $session->getSchema("food");
$schema->createCollection("trees");

// ...

$trees $schema->getCollection("trees");

// ...

// Is this collection still in the database (schema)?
if ($trees->existsInDatabase()) {
    echo 
"Yes, the 'trees' collection is still present.";
}

上の例の出力は、 たとえば以下のようになります。

Yes, the 'trees' collection is still present.