php-doc-en/reference/mysqlnd_qc/functions/mysqlnd-qc-set-cache-condition.xml
Yannick Torres 18046e0224 Fix svn keywords
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@325489 c90b9560-bf6c-de11-be94-00142212c4b1
2012-05-01 12:31:16 +00:00

161 lines
4.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.mysqlnd-qc-set-cache-condition" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>mysqlnd_qc_set_cache_condition</refname>
<refpurpose>Set conditions for automatic caching</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type>
<methodname>mysqlnd_qc_set_cache_condition</methodname>
<methodparam>
<type>int</type>
<parameter>condition_type</parameter>
</methodparam>
<methodparam>
<type>mixed</type>
<parameter>condition</parameter>
</methodparam>
<methodparam>
<type>mixed</type>
<parameter>condition_option</parameter>
</methodparam>
</methodsynopsis>
<para>
Sets a condition for automatic caching of statements which do not contain
the necessary SQL hints to enable caching of them.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term>
<parameter>condition_type</parameter>
</term>
<listitem>
<para>
Type of the condition. The only allowed value is
<constant>MYSQLND_QC_CONDITION_META_SCHEMA_PATTERN</constant>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>condition</parameter>
</term>
<listitem>
<para>
Parameter for the condition set with <literal>condition_type</literal>.
Parameter type and structure depend on <literal>condition_type</literal>
</para>
<para>
If <literal>condition_type</literal> equals
<literal>MYSQLND_QC_CONDITION_META_SCHEMA_PATTERN</literal>
<literal>condition</literal> must be a string. The string sets a pattern.
Statements are cached if table and database meta data entry of their result sets
match the pattern. The pattern is checked for a match with the
<literal>db</literal> and <literal>org_table</literal> meta data entries
provided by the underlying MySQL client server library. Please, check
the MySQL Reference manual for details about the two entries. The
<literal>db</literal> and <literal>org_table</literal> values are
concatenated with a dot (<literal>.</literal>) before matched
against <literal>condition</literal>. Pattern matching supports
the wildcards <literal>%</literal> and <literal>_</literal>.
The wildcard <literal>%</literal> will match one or many arbitrary
characters. <literal>_</literal> will match one arbitrary character.
The escape symbol is backslash.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>condition_option</parameter>
</term>
<listitem>
<para>
Option for <literal>condition</literal>. Type and structure depend
on <literal>condition_type</literal>.
</para>
<para>
If <literal>condition_type</literal> equals
<literal>MYSQLND_QC_CONDITION_META_SCHEMA_PATTERN</literal>
<literal>condition_options</literal> is the TTL to be used.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>mysqlnd_qc_set_cache_condition</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
/* Cache all accesses to tables with the name "new%" in schema/database "db_example" for 1 second */
if (!mysqlnd_qc_set_cache_condition(MYSQLND_QC_CONDITION_META_SCHEMA_PATTERN, "db_example.new%", 1)) {
die("Failed to set cache condition!");
}
$mysqli = new mysqli("host", "user", "password", "db_example", "port");
/* cached although no SQL hint given */
$mysqli->query("SELECT id, title FROM news");
$pdo_mysql = new PDO("mysql:host=host;dbname=db_example;port=port", "user", "password");
/* not cached: no SQL hint, no pattern match */
$pdo_mysql->query("SELECT id, title FROM latest_news");
/* cached: TTL 1 second, pattern match */
$pdo_mysql->query("SELECT id, title FROM news");
?>
]]>
</programlisting>
</example>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns TRUE on success or FALSE on FAILURE.
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member>
<link linkend="mysqlnd-qc.pattern-based-caching">Quickstart: pattern based caching</link>
</member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->