Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 9801

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Predefined Constants</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mysqlnd-qc.configuration.html">Runtime Configuration</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.mysqlnd-qc.html">mysqlnd_qc Functions</a></div>
 <div class="up"><a href="book.mysqlnd-qc.html">mysqlnd_qc</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mysqlnd-qc.constants" class="appendix">
 <h1>Predefined Constants</h1>

 <p class="simpara">
The constants below are defined by this extension, and
will only be available when the extension has either
been compiled into PHP or dynamically loaded at runtime.
</p>
 <p class="para">
  <em class="emphasis">SQL hint related</em>
 </p>
 <p class="para">
  <div class="example" id="example-1860">
   <p><strong>Example #1 Using SQL hint constants</strong></p>
   <div class="example-contents"><p>
    The query cache is controlled by SQL hints. SQL hints are used to enable and
    disable caching. SQL hints can be used to set the
    <em>TTL</em> of a query.
   </p></div>
   <div class="example-contents"><p>
    The SQL hints recognized by the query cache can be manually changed at
    compile time. This makes it possible to use
    <em>mysqlnd_qc</em> in environments in which the default
    SQL hints are already taken and interpreted by other systems. Therefore
    it is recommended to use the SQL hint string constants instead of
    manually adding the default SQL hints to the query string.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;Use&nbsp;constants&nbsp;for&nbsp;maximum&nbsp;portability&nbsp;*/<br /></span><span style="color: #0000BB">$query&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"/*"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">MYSQLND_QC_ENABLE_SWITCH&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"*/SELECT&nbsp;id&nbsp;FROM&nbsp;test"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/*&nbsp;Valid&nbsp;but&nbsp;less&nbsp;portable:&nbsp;default&nbsp;TTL&nbsp;*/<br /></span><span style="color: #0000BB">$query&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"/*qc=on*/SELECT&nbsp;id&nbsp;FROM&nbsp;test"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/*&nbsp;Valid&nbsp;but&nbsp;less&nbsp;portable:&nbsp;per&nbsp;statement&nbsp;TTL&nbsp;*/<br /></span><span style="color: #0000BB">$query&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"/*qc=on*//*qc_ttl=5*/SELECT&nbsp;id&nbsp;FROM&nbsp;test"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"MYSQLND_QC_ENABLE_SWITCH:&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">MYSQLND_QC_ENABLE_SWITCH</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"MYSQLND_QC_DISABLE_SWITCH:&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">MYSQLND_QC_DISABLE_SWITCH</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"MYSQLND_QC_TTL_SWITCH:&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">MYSQLND_QC_TTL_SWITCH</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>The above examples will output:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
MYSQLND_QC_ENABLE_SWITCH: qc=on
MYSQLND_QC_DISABLE_SWITCH: qc=off
MYSQLND_QC_TTL_SWITCH: qc_ttl=

</pre></div>
   </div>

  </div>
 </p>

 <p class="para">
  <dl>

   <dt id="constant.mysqlnd-qc-enable-switch">
    <span class="term">
     <strong><code>MYSQLND_QC_ENABLE_SWITCH</code></strong>
     (<span class="type"><a href="language.types.string.html" class="type string">string</a></span>)
    </span>
    <dd>

     <span class="simpara">
      SQL hint used to enable caching of a query.
     </span>
    </dd>

   </dt>

   <dt id="constant.mysqlnd-qc-disable-switch">
    <span class="term">
     <strong><code>MYSQLND_QC_DISABLE_SWITCH</code></strong>
     (<span class="type"><a href="language.types.string.html" class="type string">string</a></span>)
    </span>
    <dd>

     <span class="simpara">
      SQL hint used to disable caching of a query if
      <em>mysqlnd_qc.cache_by_default = 1</em>.
     </span>
    </dd>

   </dt>

   <dt id="constant.mysqlnd-qc-ttl-switch">
    <span class="term">
     <strong><code>MYSQLND_QC_TTL_SWITCH</code></strong>
     (<span class="type"><a href="language.types.string.html" class="type string">string</a></span>)
    </span>
    <dd>

     <span class="simpara">
      SQL hint used to set the TTL of a result set.
     </span>
    </dd>

   </dt>

   <dt id="constant.mysqlnd-qc-server-id">
    <span class="term">
     <strong><code>MYSQLND_QC_SERVER_ID_SWITCH</code></strong>
     (<span class="type"><a href="language.types.string.html" class="type string">string</a></span>)
    </span>
    <dd>

     <span class="simpara">
      This SQL hint should not be used in general.
     </span>
     <span class="simpara">
      It is needed by <a href="book.mysqlnd-ms.html" class="link">PECL/mysqlnd_ms</a>
      to group cache entries for one statement
      but originating from different physical connections. If the
      hint is used connection settings such as user, hostname and charset
      are not considered for generating a cache key of a query.
      Instead the given value and the query string are used as input
      to the hashing function that generates the key.
     </span>
     <span class="simpara">
      PECL/mysqlnd_ms may, if instructed, cache results from
      MySQL Replication slaves. Because it can hold many connections
      to the slave the cache key shall not be formed from the user,
      hostname or other settings that may vary for the various slave
      connections. Instead, PECL/mysqlnd_ms provides an identifier
      which refers to the group of slave connections that shall be enabled
      to share cache entries no matter which physical slave connection was
      to generate the cache entry.
     </span>
     <span class="simpara">
      Use of this feature outside of PECL/mysqlnd_ms is not recommended.
     </span>
    </dd>

   </dt>

  </dl>

 </p>
 <p class="para">
  <em class="emphasis"> <span class="function"><a href="function.mysqlnd-qc-set-cache-condition.html" class="function">mysqlnd_qc_set_cache_condition()</a></span> related</em>
 </p>
 <p class="para">
  <div class="example" id="example-1861">
   <p><strong>Example #2 Example  <span class="function"><a href="function.mysqlnd-qc-set-cache-condition.html" class="function">mysqlnd_qc_set_cache_condition()</a></span> usage</strong></p>
   <div class="example-contents"><p>
    The function  <span class="function"><a href="function.mysqlnd-qc-set-cache-condition.html" class="function">mysqlnd_qc_set_cache_condition()</a></span> allows setting conditions
    for automatic caching of statements which don&#039;t begin with the SQL hints
    necessary to manually enable caching.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;Cache&nbsp;all&nbsp;accesses&nbsp;to&nbsp;tables&nbsp;with&nbsp;the&nbsp;name&nbsp;"new%"&nbsp;in&nbsp;schema/database&nbsp;"db_example"&nbsp;for&nbsp;1&nbsp;second&nbsp;*/<br /></span><span style="color: #007700">if&nbsp;(!</span><span style="color: #0000BB">mysqlnd_qc_set_cache_condition</span><span style="color: #007700">(</span><span style="color: #0000BB">MYSQLND_QC_CONDITION_META_SCHEMA_PATTERN</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"db_example.new%"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;die(</span><span style="color: #DD0000">"Failed&nbsp;to&nbsp;set&nbsp;cache&nbsp;condition!"</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$mysqli&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">mysqli</span><span style="color: #007700">(</span><span style="color: #DD0000">"host"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"user"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"password"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"db_example"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"port"</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">/*&nbsp;cached&nbsp;although&nbsp;no&nbsp;SQL&nbsp;hint&nbsp;given&nbsp;&nbsp;*/<br /></span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;id,&nbsp;title&nbsp;FROM&nbsp;news"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$pdo_mysql&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">PDO</span><span style="color: #007700">(</span><span style="color: #DD0000">"mysql:host=host;dbname=db_example;port=port"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"user"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"password"</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">/*&nbsp;not&nbsp;cached:&nbsp;no&nbsp;SQL&nbsp;hint,&nbsp;no&nbsp;pattern&nbsp;match&nbsp;*/<br /></span><span style="color: #0000BB">$pdo_mysql</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;id,&nbsp;title&nbsp;FROM&nbsp;latest_news"</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">/*&nbsp;cached:&nbsp;TTL&nbsp;1&nbsp;second,&nbsp;pattern&nbsp;match&nbsp;*/<br /></span><span style="color: #0000BB">$pdo_mysql</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;id,&nbsp;title&nbsp;FROM&nbsp;news"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </p>
 <p class="para">
  <dl>

   <dt id="constant.mysqlnd-qc-condition-meta-schema-pattern">
    <span class="term">
     <strong><code>MYSQLND_QC_CONDITION_META_SCHEMA_PATTERN</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type int">int</a></span>)
    </span>
    <dd>

     <span class="simpara">
      Used as a parameter of  <span class="function"><a href="function.mysqlnd-qc-set-cache-condition.html" class="function">mysqlnd_qc_set_cache_condition()</a></span>
      to set conditions for schema based automatic caching.
     </span>
    </dd>

   </dt>

  </dl>

 </p>
 <p class="para">
  <em class="emphasis">Other</em>
 </p>
 <p class="para">
  The plugin version number can be obtained using either
  <strong><code>MYSQLND_QC_VERSION</code></strong>, which is the string representation 
  of the numerical version number, or <strong><code>MYSQLND_QC_VERSION_ID</code></strong>, 
  which is an integer such as 10000. Developers can calculate the version number 
  as follows.
 </p>
 <p class="para">
   <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version (part)</th>
      <th>Example</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>Major*10000</td>
      <td>1*10000 = 10000</td>
     </tr>

     <tr>
      <td>Minor*100</td>
      <td>0*100 = 0</td>
     </tr>

     <tr>
      <td>Patch</td>
      <td>0 = 0</td>
     </tr>

     <tr>
      <td>MYSQLND_QC_VERSION_ID</td>
      <td>10000</td>
     </tr>

    </tbody>
   
  </table>

 </p>
 <p class="para">
  <dl>

   <dt id="constant.mysqlnd-qc-version">
    <span class="term">
     <strong><code>MYSQLND_QC_VERSION</code></strong>
     (<span class="type"><a href="language.types.string.html" class="type string">string</a></span>)
    </span>
    <dd>

     <span class="simpara">
      Plugin version string, for example, "<span class="quote">1.0.0-prototype</span>".
     </span>
    </dd>

   </dt>

  </dl>

 </p>
 <p class="para">
  <dl>

   <dt id="constant.mysqlnd-qc-version-id">
    <span class="term">
     <strong><code>MYSQLND_QC_VERSION_ID</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type int">int</a></span>)
    </span>
    <dd>

     <span class="simpara">
      Plugin version number, for example, 10000.
     </span>
    </dd>

   </dt>

  </dl>

 </p>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mysqlnd-qc.configuration.html">Runtime Configuration</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.mysqlnd-qc.html">mysqlnd_qc Functions</a></div>
 <div class="up"><a href="book.mysqlnd-qc.html">mysqlnd_qc</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>