PHP Conference Japan 2024

Schema::existsInDatabase

(沒有版本資訊,可能只在 Git 中)

Schema::existsInDatabase檢查是否存在於資料庫中

說明

public mysql_xdevapi\Schema::existsInDatabase(): bool

檢查目前的物件(schema、table、collection 或 view)是否存在於 schema 物件中。

參數

此函式沒有參數。

回傳值

如果 schema、table、collection 或 view 仍然存在於 schema 中,則回傳 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");

// ...

// 這個集合是否還在資料庫(schema)中?
if ($trees->existsInDatabase()) {
echo
"是的,'trees' 集合仍然存在。";
}

上述範例將會輸出類似以下的內容:

Yes, the 'trees' collection is still present.
新增註記

使用者提供的註記

此頁面沒有使用者提供的註記。
To Top