Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 9752

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-ms.monitoring.html">Monitoring</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.mysqlnd-ms.html">Mysqlnd_ms Functions</a></div>
 <div class="up"><a href="book.mysqlnd-ms.html">mysqlnd_ms</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mysqlnd-ms.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-1837">
   <p><strong>Example #1 Example demonstrating the usage of mysqlnd_ms constants</strong></p>
   <div class="example-contents"><p>
    The mysqlnd replication and load balancing plugin (<em>mysqlnd_ms</em>)
    performs read/write splitting. This directs write queries to a MySQL
    master server, and read-only queries to the MySQL slave servers.
    The plugin has a built-in read/write split logic.
    All queries which start with <em>SELECT</em> are considered read-only
    queries, which are then sent to a MySQL slave server that is listed in
    the plugin configuration file. All other queries are directed to the
    MySQL master server that is also specified in the plugin configuration file.
   </p></div>
   <div class="example-contents"><p>
    User supplied SQL hints can be used to overrule automatic read/write splitting,
    to gain full control on the process. SQL hints are standards compliant
    SQL comments. The plugin will scan the beginning of a query string for
    an SQL comment for certain commands, which then control query redirection.
    Other systems involved in the query processing are unaffected by the
    SQL hints because other systems will ignore the SQL comments.
   </p></div>
   <div class="example-contents"><p>
    The plugin supports three SQL hints to direct queries to either the MySQL slave
    servers, the MySQL master server, or the last used MySQL server. SQL hints
    must be placed at the beginning of a query to be recognized by the plugin.
   </p></div>
   <div class="example-contents"><p>
    For better portability, it is recommended to use the string constants
    <strong><code>MYSQLND_MS_MASTER_SWITCH</code></strong>,
    <strong><code>MYSQLND_MS_SLAVE_SWITCH</code></strong> and
    <strong><code>MYSQLND_MS_LAST_USED_SWITCH</code></strong> instead of their literal
    values.
   </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">$master_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_MS_MASTER_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;using&nbsp;literal&nbsp;instead&nbsp;of&nbsp;constant&nbsp;*/<br /></span><span style="color: #0000BB">$slave_query&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"/*ms=slave*/SHOW&nbsp;TABLES"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"master_query&nbsp;=&nbsp;'%s'\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$master_query</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"slave_query&nbsp;=&nbsp;'%s'\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$slave_query</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>
master_query = /*ms=master*/SELECT id FROM test
slave_query = /*ms=slave*/SHOW TABLES
</pre></div>
   </div>
  </div>
 </p>
 <p class="para">
  <dl>

   <dt id="constant.mysqlnd-ms-master-switch">
    <span class="term">
     <strong><code>MYSQLND_MS_MASTER_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 send a query to the MySQL replication master server.
     </span>
    </dd>

   </dt>

   <dt id="constant.mysqlnd-ms-slave-switch">
    <span class="term">
     <strong><code>MYSQLND_MS_SLAVE_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 send a query to one of the MySQL replication slave servers.
     </span>
    </dd>

   </dt>

   <dt id="constant.mysqlnd-ms-last-used-switch">
    <span class="term">
     <strong><code>MYSQLND_MS_LAST_USED_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 send a query to the last used MySQL server. The last
      used MySQL server can either be a master or a slave server in a
      MySQL replication setup.
     </span>
    </dd>

   </dt>

  </dl>

 </p>

 <p class="para">
   <span class="function"><a href="function.mysqlnd-ms-query-is-select.html" class="function">mysqlnd_ms_query_is_select()</a></span>
  related
 </p>
 <p class="para">
  <dl>

   <dt id="constant.mysqlnd-ms-query-use-master">
    <span class="term">
     <strong><code>MYSQLND_MS_QUERY_USE_MASTER</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
    </span>
    <dd>

     <span class="simpara">
     If  <span class="function"><strong>mysqlnd_ms_is_select()</strong></span> returns
     <strong><code>MYSQLND_MS_QUERY_USE_MASTER</code></strong> for a given query, the
     built-in read/write split mechanism recommends sending the query to
     a MySQL replication master server.
     </span>
    </dd>

   </dt>

   <dt id="constant.mysqlnd-ms-query-use-slave">
    <span class="term">
     <strong><code>MYSQLND_MS_QUERY_USE_SLAVE</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
    </span>
    <dd>

     <span class="simpara">
      If  <span class="function"><strong>mysqlnd_ms_is_select()</strong></span> returns
      <strong><code>MYSQLND_MS_QUERY_USE_SLAVE</code></strong> for a given query, the
      built-in read/write split mechanism recommends sending the query to
      a MySQL replication slave server.
     </span>
    </dd>

   </dt>

   <dt id="constant.mysqlnd-ms-query-use-last-used">
    <span class="term">
     <strong><code>MYSQLND_MS_QUERY_USE_LAST_USED</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
    </span>
    <dd>

     <span class="simpara">
      If  <span class="function"><strong>mysqlnd_ms_is_select()</strong></span> returns
      <strong><code>MYSQLND_MS_QUERY_USE_LAST_USED</code></strong> for a given query, the
      built-in read/write split mechanism recommends sending the query to
      the last used server.
     </span>
    </dd>

   </dt>

  </dl>

 </p>

 <p class="para">
   <span class="function"><a href="function.mysqlnd-ms-set-qos.html" class="function">mysqlnd_ms_set_qos()</a></span>,
  quality of service filter and service level related
 </p>
 <p class="para">
  <dl>

   <dt id="constant.mysqlnd-ms-qos-consistency-eventual">
    <span class="term">
     <strong><code>MYSQLND_MS_QOS_CONSISTENCY_EVENTUAL</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
    </span>
    <dd>

     <span class="simpara">
      Use to request the service level eventual consistency from the
       <span class="function"><a href="function.mysqlnd-ms-set-qos.html" class="function">mysqlnd_ms_set_qos()</a></span>. Eventual consistency is the
      default quality of service when reading from an asynchronous MySQL
      replication slave. Data returned in this service level may or may not
      be stale, depending on whether the selected slaves happen to have replicated
      the latest changes from the MySQL replication master or not.
     </span>
    </dd>

   </dt>

   <dt id="constant.mysqlnd-ms-qos-consistency-session">
    <span class="term">
     <strong><code>MYSQLND_MS_QOS_CONSISTENCY_SESSION</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
    </span>
    <dd>

     <span class="simpara">
      Use to request the service level session consistency from the
       <span class="function"><a href="function.mysqlnd-ms-set-qos.html" class="function">mysqlnd_ms_set_qos()</a></span>. Session consistency
      is defined as read your writes. The client is guaranteed to see his
      latest changes.
     </span>
    </dd>

   </dt>

   <dt id="constant.mysqlnd-ms-qos-consistency-strong">
    <span class="term">
     <strong><code>MYSQLND_MS_QOS_CONSISTENCY_STRONG</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
    </span>
    <dd>

     <span class="simpara">
      Use to request the service level strong consistency from the
       <span class="function"><a href="function.mysqlnd-ms-set-qos.html" class="function">mysqlnd_ms_set_qos()</a></span>. Strong consistency
      is used to ensure all clients see each others changes.
     </span>
    </dd>

   </dt>

   <dt id="constant.mysqlnd-ms-qos-option-gtid">
    <span class="term">
     <strong><code>MYSQLND_MS_QOS_OPTION_GTID</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
    </span>
    <dd>

     <span class="simpara">
      Used as a service level option with
       <span class="function"><a href="function.mysqlnd-ms-set-qos.html" class="function">mysqlnd_ms_set_qos()</a></span> to parameterize session
      consistency.
     </span>
    </dd>

   </dt>

   <dt id="constant.mysqlnd-ms-qos-option-age">
    <span class="term">
     <strong><code>MYSQLND_MS_QOS_OPTION_AGE</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
    </span>
    <dd>

     <span class="simpara">
      Used as a service level option with
       <span class="function"><a href="function.mysqlnd-ms-set-qos.html" class="function">mysqlnd_ms_set_qos()</a></span> to parameterize eventual
      consistency.
     </span>
    </dd>

   </dt>

  </dl>

 </p>

 <p class="para">
  <em class="emphasis">Other</em>
 </p>
 <p class="para">
  The plugins version number can be obtained using
  <strong><code>MYSQLND_MS_VERSION</code></strong> or
  <strong><code>MYSQLND_MS_VERSION_ID</code></strong>.
  <strong><code>MYSQLND_MS_VERSION</code></strong>
  is the string representation of the numerical version number
  <strong><code>MYSQLND_MS_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_MS_VERSION_ID</td>
      <td>10000</td>
     </tr>

    </tbody>
   
  </table>

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

   <dt id="constant.mysqlnd-ms-version">
    <span class="term">
     <strong><code>MYSQLND_MS_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>

   <dt id="constant.mysqlnd-ms-version-id">
    <span class="term">
     <strong><code>MYSQLND_MS_VERSION_ID</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</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-ms.monitoring.html">Monitoring</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.mysqlnd-ms.html">Mysqlnd_ms Functions</a></div>
 <div class="up"><a href="book.mysqlnd-ms.html">mysqlnd_ms</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>