<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >MySQL Functions (PDO_MYSQL)</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Referência das Funções" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="mysql_unbuffered_query" HREF="function.mysql-unbuffered-query.html"><LINK REL="NEXT" TITLE="PDO_MYSQL DSN" HREF="ref.pdo-mysql.connection.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.mysql-unbuffered-query.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="ref.pdo-mysql.connection.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.pdo-mysql" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >XCIX. MySQL Functions (PDO_MYSQL)</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN132044" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="pdo-mysql.intro" >Introdução</A ></H1 ><P > PDO_MYSQL is a driver that implements the <A HREF="ref.pdo.html" >PHP Data Objects (PDO) interface</A > to enable access from PHP to MySQL 3.x, 4.x and 5.x databases. </P ><P > PDO_MYSQL will take advantage of native prepared statement support present in MySQL 4.1 and higher. If you're using an older version of the mysql client libraries, PDO will emulate them for you. </P ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Atenção</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > Beware: Some MySQL table types (storage engines) do not support transactions. When writing transactional database code using a table type that does not support transactions, MySQL will pretend that a transaction was initiated successfully. In addition, any DDL queries issued will implicitly commit any pending transactions. </P ></TD ></TR ></TABLE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="pdo-mysql.constants" >Constantes pré-definidas</A ></H1 ><P >As constantes abaixo são definidas por este drive, e somente estarão disponíveis quando esta extensão for compilada no PHP ou carregada dinamicamente em tempo de execução. Em adição, estas constantes especificas do drive somente devem ser usadas se você estive usando este drive. Usar atributos especificos do mysql com o driver postgree pode resultar em um funcionamento não esperado. <B CLASS="function" >PDO::getAttribute()</B > deve ser usado para obter o atributo <TT CLASS="constant" ><B >PDO_ATTR_DRIVER_NAME</B ></TT > para se certificar do driver, se o seu código puder ser usado com vários drivers.</P ><P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >PDO::MYSQL_ATTR_USE_BUFFERED_QUERY</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > If this attribute is set to <TT CLASS="constant" ><B >TRUE</B ></TT > on a <B CLASS="classname" >PDOStatement</B >, the MySQL driver will use the buffered versions of the MySQL API. If you're writing portable code, you should use <B CLASS="function" >PDOStatement::fetchAll()</B > instead. </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN132068" ></A ><P ><B >Exemplo 1. Forcing queries to be buffered in mysql</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /></font><font color="#007700">if (</font><font color="#0000BB">$db</font><font color="#007700">-></font><font color="#0000BB">getAttribute</font><font color="#007700">(</font><font color="#0000BB">PDO</font><font color="#007700">::</font><font color="#0000BB">ATTR_DRIVER_NAME</font><font color="#007700">) == </font><font color="#DD0000">'mysql'</font><font color="#007700">) {<br /> </font><font color="#0000BB">$stmt </font><font color="#007700">= </font><font color="#0000BB">$db</font><font color="#007700">-></font><font color="#0000BB">prepare</font><font color="#007700">(</font><font color="#DD0000">'select * from foo'</font><font color="#007700">,<br /> array(</font><font color="#0000BB">PDO</font><font color="#007700">::</font><font color="#0000BB">MYSQL_ATTR_USE_BUFFERED_QUERY </font><font color="#007700">=> </font><font color="#0000BB">true</font><font color="#007700">));<br />} else {<br /> die(</font><font color="#DD0000">"my application only works with mysql; I should use \$stmt->fetchAll() instead"</font><font color="#007700">);<br />}<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DD ><DT ><TT CLASS="constant" ><B >PDO::MYSQL_ATTR_LOCAL_INFILE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > Enable <TT CLASS="literal" >LOAD LOCAL INFILE</TT >. </P ></DD ><DT ><TT CLASS="constant" ><B >PDO::MYSQL_ATTR_INIT_COMMAND</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > Command to execute when connecting to the MySQL server. Will automatically be re-executed when reconnecting. </P ></DD ><DT ><TT CLASS="constant" ><B >PDO::MYSQL_ATTR_READ_DEFAULT_FILE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > Read options from the named option file instead of from <TT CLASS="filename" >my.cnf</TT >. </P ></DD ><DT ><TT CLASS="constant" ><B >PDO::MYSQL_ATTR_READ_DEFAULT_GROUP</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > Read options from the named group from <TT CLASS="filename" >my.cnf</TT > or the file specified with <TT CLASS="constant" ><B >MYSQL_READ_DEFAULT_FILE</B ></TT >. </P ></DD ><DT ><TT CLASS="constant" ><B >PDO::MYSQL_ATTR_MAX_BUFFER_SIZE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > Maximum buffer size. Defaults to 1 MiB. </P ></DD ><DT ><TT CLASS="constant" ><B >PDO::MYSQL_ATTR_DIRECT_QUERY</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > Perform direct queries, don't use prepared statements. </P ></DD ></DL ></DIV ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Índice</B ></DT ><DT ><A HREF="ref.pdo-mysql.connection.html" >PDO_MYSQL DSN</A > -- Connecting to MySQL databases</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.mysql-unbuffered-query.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="ref.pdo-mysql.connection.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >mysql_unbuffered_query</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >PDO_MYSQL DSN</TD ></TR ></TABLE ></DIV ></BODY ></HTML >