<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.mongodb-driver-clientencryption.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ru',
  ),
  'this' => 
  array (
    0 => 'mongodb-driver-clientencryption.encryptexpression.php',
    1 => 'MongoDB\\Driver\\ClientEncryption::encryptExpression',
    2 => 'Шифрует совпадение или агрегированное выражение',
  ),
  'up' => 
  array (
    0 => 'class.mongodb-driver-clientencryption.php',
    1 => 'MongoDB\\Driver\\ClientEncryption',
  ),
  'prev' => 
  array (
    0 => 'mongodb-driver-clientencryption.encrypt.php',
    1 => 'MongoDB\\Driver\\ClientEncryption::encrypt',
  ),
  'next' => 
  array (
    0 => 'mongodb-driver-clientencryption.getkey.php',
    1 => 'MongoDB\\Driver\\ClientEncryption::getKey',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ru',
    'path' => 'reference/mongodb/mongodb/driver/clientencryption/encryptexpression.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="mongodb-driver-clientencryption.encryptexpression" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\Driver\ClientEncryption::encryptExpression</h1>
  <p class="verinfo">(mongodb &gt;=1.16.0)</p><p class="refpurpose"><span class="refname">MongoDB\Driver\ClientEncryption::encryptExpression</span> &mdash; <span class="dc-title">Шифрует совпадение или агрегированное выражение</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-driver-clientencryption.encryptexpression-description">
  <h3 class="title">Описание</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\Driver\ClientEncryption::encryptExpression</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.object.php" class="type object">object</a></span></span> <code class="parameter">$expr</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.array.php" class="type array">array</a></span></span> <code class="parameter">$options</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.object.php" class="type object">object</a></span></div>

  <p class="para rdfs-comment">
   Метод шифрует совпадение или агрегированное выражение для запроса индекса диапазона.
  </p>
  <p class="para">
   Для выполнения запроса с зашифрованным диапазоном полезной нагрузки
   драйвер <span class="classname"><a href="class.mongodb-driver-manager.php" class="classname">MongoDB\Driver\Manager</a></span> конфигурируют
   с опцией <code class="literal">&quot;autoEncryption&quot;</code>.
   Опция <code class="literal">&quot;bypassQueryAnalysis&quot;</code> автоматического шифрования принимает значение <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
   Для опции автоматического шифрования <code class="literal">&quot;bypassAutoEncryption&quot;</code> устанавливают значение <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
  </p>
  <blockquote class="note"><p><strong class="note">Замечание</strong>: 
   <p class="para">
    Модуль пока не поддерживает запросы диапазонов для BSON-полей с типом Decimal128.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-driver-clientencryption.encryptexpression-parameters">
  <h3 class="title">Список параметров</h3>
  <dl>
   
    <dt><code class="parameter">expr</code></dt>
    <dd>
     <p class="para">
      Соответствие или агрегированное выражение, которое требуется зашифровать.
      В выражениях указывают хотя бы один оператор из списка:
      <code class="literal">$gt</code>, <code class="literal">$gte</code>,
      <code class="literal">$lt</code> или <code class="literal">$lte</code>.
      Оператор верхнего уровня <code class="literal">$and</code> необходим,
      даже если используется только один оператор сравнения.
     </p>
     <p class="para">
      Пример поддерживаемого выражения соответствия (применяется для запросов
      и этапа агрегации <code class="literal">$match</code>) выглядит следующим образом:
     </p>
     <div class="example-contents">
<div class="textcode"><pre class="textcode">[
    &#039;$and&#039; =&gt; [
        [ &#039;&lt;field&gt;&#039; =&gt; [ &#039;$gt&#039;  =&gt; &#039;&lt;value1&gt;&#039; ] ],
        [ &#039;&lt;field&gt;&#039; =&gt; [ &#039;$lte&#039; =&gt; &#039;&lt;value2&gt;&#039; ] ],
    ],
]</pre>
</div>
     </div>

     <p class="para">
      Пример поддерживаемого агрегированного выражения выглядит следующим образом:
     </p>
     <div class="example-contents">
<div class="textcode"><pre class="textcode">[
    &#039;$and&#039; =&gt; [
        [ &#039;$gte&#039; =&gt; [ &#039;&lt;fieldPath&gt;&#039;, &#039;&lt;value1&gt;&#039; ] ],
        [ &#039;$lt&#039;  =&gt; [ &#039;&lt;fieldPath&gt;&#039;, &#039;&lt;value2&gt;&#039; ] ],
    ],
]</pre>
</div>
     </div>

    </dd>
   
   
   
    <dt><code class="parameter">options</code></dt>
    <dd>
     <p class="para">
      <table class="doctable table">
       <caption><strong>Encryption options</strong></caption>
       
        <thead>
         <tr>
          <th>Опция</th>
          <th>Тип</th>
          <th>Описание</th>
         </tr>

        </thead>

        <tbody class="tbody">
         <tr>
          <td>algorithm</td>
          <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
          <td>
           <p class="para">
            Алгоритм шифрования, который будет использоваться. Опция обязательна.
            Укажите одну из следующих
            <a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants" class="link">констант ClientEncryption</a>:
           </p>
           <ul class="simplelist">
            <li><strong><code>MongoDB\Driver\ClientEncryption::AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC</code></strong></li>
            <li><strong><code>MongoDB\Driver\ClientEncryption::AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM</code></strong></li>
            <li><strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.algorithm-indexed">MongoDB\Driver\ClientEncryption::ALGORITHM_INDEXED</a></code></strong></li>
            <li><strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.algorithm-unindexed">MongoDB\Driver\ClientEncryption::ALGORITHM_UNINDEXED</a></code></strong></li>
            <li><strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.algorithm-range">MongoDB\Driver\ClientEncryption::ALGORITHM_RANGE</a></code></strong></li>
           </ul>
          </td>
         </tr>

         <tr>
          <td>contentionFactor</td>
          <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
          <td>
           <p class="para">
            Коэффициент конкуренции для оценки запросов с индексированными
            зашифрованными полезными нагрузками.
           </p>
           <p class="para">
            Опция применяется и может быть указана только тогда, когда
            опция <code class="literal">algorithm</code> равна
            <strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.algorithm-indexed">MongoDB\Driver\ClientEncryption::ALGORITHM_INDEXED</a></code></strong>
            или
            <strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.algorithm-range">MongoDB\Driver\ClientEncryption::ALGORITHM_RANGE</a></code></strong>.
           </p>
          </td>
         </tr>

         <tr>
          <td>keyAltName</td>
          <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
          <td>
           <p class="para">
            Идентифицирует документ коллекции хранилища ключей по <code class="literal">keyAltName</code>.
            Опция является взаимоисключающей с <code class="literal">keyId</code> и требуется ровно один.
           </p>
          </td>
         </tr>

         <tr>
          <td>keyId</td>
          <td><span class="classname"><a href="class.mongodb-bson-binary.php" class="classname">MongoDB\BSON\Binary</a></span></td>
          <td>
           <p class="para">
            Идентифицирует ключ данных по <code class="literal">_id</code>. Значением является UUID
            (двоичный подтип 4). Опция является взаимоисключающей с <code class="literal">keyAltName</code>
            и требуется ровно один.
           </p>
          </td>
         </tr>

         <tr>
          <td>queryType</td>
          <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
          <td>
           <p class="para">
            Тип запроса для оценки запросов с индексированными, зашифрованными
            полезными нагрузками. Укажите одну из следующих
            <a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants" class="link">констант ClientEncryption</a>:
           </p>
           <ul class="simplelist">
            <li><strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.query-type-equality">MongoDB\Driver\ClientEncryption::QUERY_TYPE_EQUALITY</a></code></strong></li>
            <li><strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.query-type-range">MongoDB\Driver\ClientEncryption::QUERY_TYPE_RANGE</a></code></strong></li>
           </ul>
           <p class="para">
            Опция применяется и может быть указана только тогда, когда
            опция <code class="literal">algorithm</code> равна
            <strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.algorithm-indexed">MongoDB\Driver\ClientEncryption::ALGORITHM_INDEXED</a></code></strong>
            или <strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.algorithm-range">MongoDB\Driver\ClientEncryption::ALGORITHM_RANGE</a></code></strong>.
           </p>
          </td>
         </tr>

         <tr>
          <td>rangeOpts</td>
          <td><span class="type"><a href="language.types.array.php" class="type array">array</a></span></td>
          <td>
           <p class="para">
            Опции индекса для шифруемого поля с поддержкой запросов «range».
            Параметры, которые приводят следующие абзацы, должны соответствовать значениям, которые установили
            в параметре <code class="literal">encryptedFields</code> целевой коллекции.
            Для BSON-полей с типом double и decimal128 требуется либо установить все опции
            <code class="literal">min</code>, <code class="literal">max</code> и <code class="literal">precision</code>, либо все отключить.
           </p>
           <p class="para">
            <table class="doctable table">
             <caption><strong>Опции индекса диапазона</strong></caption>
             
              <thead>
               <tr>
                <th>Опция</th>
                <th>Тип</th>
                <th>Описание</th>
               </tr>

              </thead>

              <tbody class="tbody">
               <tr>
                <td>min</td>
                <td><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></td>
                <td>
                 Обязательна, если опцию <code class="literal">precision</code> установили. Минимальное
                 BSON-значение в диапазоне.
                </td>
               </tr>

               <tr>
                <td>max</td>
                <td><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></td>
                <td>
                 Обязательна, если опцию <code class="literal">precision</code> установили. Максимальное
                 BSON-значение в диапазоне.
                </td>
               </tr>

               <tr>
                <td>sparsity</td>
                <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
                <td>Необязательна. Опция принимает положительное 64-битное целое число.</td>
               </tr>

               <tr>
                <td>precision</td>
                <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
                <td>
                 Небязательна. Опция принимает положительное 32-битное целое число, которое указывает точность
                 для явного шифрования. Опцию устанавливают только для BSON-полей с типом double
                 или decimal128.
                </td>
               </tr>

               <tr>
                <td>trimFactor</td>
                <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
                <td>Необязательна. Положительное 32-битное целое число.</td>
               </tr>

              </tbody>
             
            </table>

           </p>
          </td>
         </tr>

        </tbody>
       
      </table>

     </p>
    </dd>
   

  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongodb-driver-clientencryption.encryptexpression-returnvalues">
  <h3 class="title">Возвращаемые значения</h3>
  <p class="para">
   Метод возвращает зашифрованное выражение в виде объекта.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-driver-clientencryption.encryptexpression-errors">
  <h3 class="title">Ошибки</h3>
  <ul class="simplelist">
   <li>При ошибке парсинга аргумента метод выбрасывает исключение  <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span>.</li>
   <li>
    Метод выбрасывает исключение <span class="classname"><a href="class.mongodb-driver-exception-encryptionexception.php" class="classname">MongoDB\Driver\Exception\EncryptionException</a></span>,
    если возникла ошибка при шифровании выражения.
   </li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongodb-driver-clientencryption.encryptexpression-changelog">
  <h3 class="title">Список изменений</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Версия</th>
       <th>Описание</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PECL-модуль mongodb 1.20.0</td>
       <td>
        В список опций параметра шифрования rangeOpts добавили опцию
        индекса диапазона <code class="literal">&quot;trimFactor&quot;</code>.
        Опция диапазона <code class="literal">&quot;sparsity&quot;</code> теперь необязательна.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongodb-driver-clientencryption.encryptexpression-seealso">
  <h3 class="title">Смотрите также</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="mongodb-driver-manager.construct.php" class="function" rel="rdfs-seeAlso">MongoDB\Driver\Manager::__construct()</a> - Создаёт нового MongoDB-менеджера</span></li>
   <li><span class="function"><a href="mongodb-driver-clientencryption.encrypt.php" class="function" rel="rdfs-seeAlso">MongoDB\Driver\ClientEncryption::encrypt()</a> - Шифрует данные</span></li>
  </ul>
 </div>


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