<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.mysql-xdevapi-collection.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'mysql-xdevapi-collection.existsindatabase.php',
    1 => 'Collection::existsInDatabase',
    2 => 'Check if collection exists in database',
  ),
  'up' => 
  array (
    0 => 'class.mysql-xdevapi-collection.php',
    1 => 'mysql_xdevapi\\Collection',
  ),
  'prev' => 
  array (
    0 => 'mysql-xdevapi-collection.dropindex.php',
    1 => 'Collection::dropIndex',
  ),
  'next' => 
  array (
    0 => 'mysql-xdevapi-collection.find.php',
    1 => 'Collection::find',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mysql_xdevapi/mysql_xdevapi/collection/existsindatabase.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="mysql-xdevapi-collection.existsindatabase" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Collection::existsInDatabase</h1>
  <p class="verinfo">(No version information available, might only be in Git)</p><p class="refpurpose"><span class="refname">Collection::existsInDatabase</span> &mdash; <span class="dc-title">Check if collection exists in database</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mysql-xdevapi-collection.existsindatabase-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>mysql_xdevapi\Collection::existsInDatabase</strong></span>(): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Checks if the Collection object refers to a collection in the database (schema).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mysql-xdevapi-collection.existsindatabase-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">У цієї функції немає
параметрів.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mysql-xdevapi-collection.existsindatabase-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> if collection exists in the database, else <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if it does not.
  </p>
  <p class="para">
    A table defined with two columns (doc and _id) is considered a collection, 
    and a third _json_schema column as of MySQL 8.0.21. 
    Adding an additional column means existsInDatabase() will no longer see it as a collection.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mysql-xdevapi-collection.existsindatabase-examples">
  <h3 class="title">Приклади</h3>
  <div class="example" id="example-1">
   <p><strong>Приклад #1 <span class="function"><strong>mysql_xdevapi\Collection::existsInDatabase()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$session </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_xdevapi\getSession</span><span style="color: #007700">(</span><span style="color: #DD0000">"mysqlx://user:password@localhost"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$session</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">sql</span><span style="color: #007700">(</span><span style="color: #DD0000">"DROP DATABASE IF EXISTS addressbook"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$session</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">sql</span><span style="color: #007700">(</span><span style="color: #DD0000">"CREATE DATABASE addressbook"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$schema </span><span style="color: #007700">= </span><span style="color: #0000BB">$session</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getSchema</span><span style="color: #007700">(</span><span style="color: #DD0000">"addressbook"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$create </span><span style="color: #007700">= </span><span style="color: #0000BB">$schema</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">createCollection</span><span style="color: #007700">(</span><span style="color: #DD0000">"people"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// ...<br /><br /></span><span style="color: #0000BB">$collection </span><span style="color: #007700">= </span><span style="color: #0000BB">$schema</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getCollection</span><span style="color: #007700">(</span><span style="color: #DD0000">"people"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// ...<br /><br /></span><span style="color: #007700">if (!</span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">existsInDatabase</span><span style="color: #007700">()) {<br />    echo </span><span style="color: #DD0000">"The collection no longer exists in the database named addressbook. What happened?"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>


</div><?php manual_footer($setup); ?>