downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/ref.pdo-mysql.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/pdo.drivers.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'ref.pdo-mysql.php',
   
1 => 'MySQL (PDO)',
  ),
 
'up' =>
  array (
   
0 => 'pdo.drivers.php',
   
1 => 'PDO Drivers',
  ),
 
'prev' =>
  array (
   
0 => 'ref.pdo-informix.connection.php',
   
1 => 'PDO_INFORMIX DSN',
  ),
 
'next' =>
  array (
   
0 => 'ref.pdo-mysql.connection.php',
   
1 => 'PDO_MYSQL DSN',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div>
  <h1 class="title">MySQL Functions (PDO_MYSQL)</h1>
 
  <div class="partintro">

   <div id="pdo-mysql.intro" class="section">
   <h2 class="title">Introduction</h2>
    <p class="para">
     PDO_MYSQL is a driver that implements the <a href="intro.pdo.php" class="link">PHP
     Data Objects (PDO) interface</a>
     to enable access from PHP to MySQL 3.x, 4.x and 5.x databases.
    </p>
    <p class="para">
     PDO_MYSQL will take advantage of native prepared statement support
     present in MySQL 4.1 and higher.  If you&#039;re using an older version of the
     mysql client libraries, PDO will emulate them for you.
    </p>
    <div class="warning"><b class="warning">Warning</b>
     <p class="para">
      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>
    </div>
   </div>
  

<div id="pdo-mysql.constants" class="section">
 <h2 class="title">Predefined Constants</h2>
 <p class="simpara">The constants below are defined by
this driver, and will only be available when the extension has been either
compiled into PHP or dynamically loaded at runtime. In addition, these
driver-specific constants should only be used if you are using this driver.
Using driver-specific attributes with another driver may result in
unexpected behaviour. <a href="pdo.getattribute.php" class="function">PDO::getAttribute()</a> may be used to
obtain the <b><tt class="constant">PDO_ATTR_DRIVER_NAME</tt></b> attribute to check the
driver, if your code can run against multiple drivers.</p>
 <dl>

  <dt class="varlistentry">

   <span class="term">
    <b><tt class="constant">PDO::MYSQL_ATTR_USE_BUFFERED_QUERY</tt></b>
     (<a href="language.types.integer.php" class="type integer">integer</a>)
   </span>

   </dt><dd class="listitem">

    <span class="simpara">
     If this attribute is set to <b><tt class="constant">TRUE</tt></b> on a
     <a href="class.pdostatement.php" class="classname">PDOStatement</a>, the MySQL driver will use the
     buffered versions of the MySQL API.  If you&#039;re writing portable code, you
     should use <a href="pdostatement.fetchall.php" class="function">PDOStatement::fetchAll()</a> instead.
    </span>
    <p class="para">
     </p><div class="example"><p><b>Example #1 Forcing queries to be buffered in mysql</b></p>
     <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getAttribute</span><span style="color: #007700">(</span><span style="color: #0000BB">PDO</span><span style="color: #007700">::</span><span style="color: #0000BB">ATTR_DRIVER_NAME</span><span style="color: #007700">)&nbsp;==&nbsp;</span><span style="color: #DD0000">'mysql'</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$stmt&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">prepare</span><span style="color: #007700">(</span><span style="color: #DD0000">'select&nbsp;*&nbsp;from&nbsp;foo'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(</span><span style="color: #0000BB">PDO</span><span style="color: #007700">::</span><span style="color: #0000BB">MYSQL_ATTR_USE_BUFFERED_QUERY&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">));<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">"my&nbsp;application&nbsp;only&nbsp;works&nbsp;with&nbsp;mysql;&nbsp;I&nbsp;should&nbsp;use&nbsp;\$stmt-&gt;fetchAll()&nbsp;instead"</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
      </div>

     </div><p>
    </p>
   </dd>

 
  <dt class="varlistentry">

   <span class="term">
    <b><tt class="constant">PDO::MYSQL_ATTR_LOCAL_INFILE</tt></b>
     (<a href="language.types.integer.php" class="type integer">integer</a>)
   </span>

   </dt><dd class="listitem">

    <p class="para">
     Enable <i>LOAD LOCAL INFILE</i>.
    </p>
   </dd>

 
  <dt class="varlistentry">

   <span class="term">
    <b><tt class="constant">PDO::MYSQL_ATTR_INIT_COMMAND</tt></b>
     (<a href="language.types.integer.php" class="type integer">integer</a>)
   </span>

   </dt><dd class="listitem">

    <p class="para">
     Command to execute when connecting to the MySQL server. Will
     automatically be re-executed when reconnecting.
    </p>
   </dd>

 
  <dt class="varlistentry">

   <span class="term">
    <b><tt class="constant">PDO::MYSQL_ATTR_READ_DEFAULT_FILE</tt></b>
     (<a href="language.types.integer.php" class="type integer">integer</a>)
   </span>

   </dt><dd class="listitem">

    <p class="para">
     Read options from the named option file instead of from
     <var class="filename">my.cnf</var>.
    </p>
   </dd>

 
  <dt class="varlistentry">

   <span class="term">
    <b><tt class="constant">PDO::MYSQL_ATTR_READ_DEFAULT_GROUP</tt></b>
     (<a href="language.types.integer.php" class="type integer">integer</a>)
   </span>

   </dt><dd class="listitem">

    <p class="para">
     Read options from the named group from <var class="filename">my.cnf</var> or the
     file specified with <b><tt class="constant">MYSQL_READ_DEFAULT_FILE</tt></b>.
    </p>
   </dd>

 
  <dt class="varlistentry">

   <span class="term">
    <b><tt class="constant">PDO::MYSQL_ATTR_MAX_BUFFER_SIZE</tt></b>
     (<a href="language.types.integer.php" class="type integer">integer</a>)
   </span>

   </dt><dd class="listitem">

    <p class="para">
     Maximum buffer size. Defaults to 1 MiB.
    </p>
   </dd>

 
  <dt class="varlistentry">

   <span class="term">
    <b><tt class="constant">PDO::MYSQL_ATTR_DIRECT_QUERY</tt></b>
     (<a href="language.types.integer.php" class="type integer">integer</a>)
   </span>

   </dt><dd class="listitem">

    <p class="para">
     Perform direct queries, don&#039;t use prepared statements.
    </p>
   </dd>

 
 </dl>

</div>



  </div>

 

 <h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="ref.pdo-mysql.connection.php">PDO_MYSQL DSN</a> — Connecting to MySQL databases</li></ul>
</div>
<?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites