php-doc-en/reference/mysqlnd_uh/functions/mysqlnd-uh-convert-to-mysqlnd.xml
2012-04-27 05:59:40 +00:00

158 lines
4.3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.mysqlnd-uh-convert-to-mysqlnd" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>mysqlnd_uh_convert_to_mysqlnd</refname>
<refpurpose>Converts a MySQL connection handle into a mysqlnd connection handle</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>resource</type>
<methodname>mysqlnd_uh_convert_to_mysqlnd</methodname>
<methodparam><type>mysqli</type><parameter role="reference">mysql_connection</parameter></methodparam>
</methodsynopsis>
<para>
Converts a MySQL connection handle into a mysqlnd connection handle.
After conversion you can execute mysqlnd library calls on the connection handle.
This can be used to access mysqlnd functionality not made available
through user space API calls.
</para>
<para>
The function can be disabled with
<literal><link linkend="ini.mysqlnd-uh.enable">mysqlnd_uh.enable</link></literal>.
If <literal><link linkend="ini.mysqlnd-uh.enable">mysqlnd_uh.enable</link></literal>
is set to &false; the function will not install the proxy and
always return &true;. Additionally, an error of the
type <literal>E_WARNING</literal> may be emitted. The error message may
read like <literal>PHP Warning: mysqlnd_uh_convert_to_mysqlnd(): (Mysqlnd User Handler)
The plugin has been disabled by setting the configuration parameter mysqlnd_uh.enable = false.
You are not allowed to call this function [...]</literal>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>MySQL connection handle</parameter></term>
<listitem>
<para>
A MySQL connection handle of type mysql, mysqli or PDO_MySQL.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A mysqlnd connection handle.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>5.4.0</entry>
<entry>
The <parameter>mysql_connection</parameter> parameter can now be of type
<literal>mysql</literal>, <literal>PDO_MySQL</literal>, or <literal>mysqli</literal>.
Before, only the <literal>mysqli</literal> type was allowed.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>mysqlnd_uh_convert_to_mysqlnd</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
/* PDO user API gives no access to connection thread id */
$mysql_connection = new PDO("mysql:host=localhost;dbname=test", "root", "");
/* Convert PDO MySQL handle to mysqlnd handle */
$mysqlnd = mysqlnd_uh_convert_to_mysqlnd($mysql_connection);
/* Create Proxy to call mysqlnd connection class methods */
$obj = new MySQLndUHConnection();
/* Call mysqlnd_conn::get_thread_id */
var_dump($obj->getThreadId($mysqlnd));
/* Use SQL to fetch connection thread id */
var_dump($mysql_connection->query("SELECT CONNECTION_ID()")->fetchAll());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(27054)
array(1) {
[0]=>
array(2) {
["CONNECTION_ID()"]=>
string(5) "27054"
[0]=>
string(5) "27054"
}
}
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member>
<literal><link linkend="ini.mysqlnd-uh.enable">mysqlnd_uh.enable</link></literal>
</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
-->