(沒有版本資訊,可能只在 Git 中)
Schema::existsInDatabase — 檢查是否存在於資料庫中
檢查目前的物件(schema、table、collection 或 view)是否存在於 schema 物件中。
此函式沒有參數。
範例 #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.