MySQL Functions (PDO_MYSQL)

Introduction

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.

Warning

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.

Installation

Use --with-pdo-mysql[=DIR]
to install
the PDO MySQL extension, where the optional [=DIR]
is the MySQL base install directory. If mysqlnd
is passed as [=DIR], then the MySQL native driver will be used.

Optionally, the --with-mysql-sock[=DIR]
sets to location
to the MySQL unix socket pointer for all MySQL extensions, including PDO_MYSQL. If
unspecified, the default locations are searched.

Optionally, the --with-zlib-dir[=DIR]
is used to set
the path to the libz install prefix.

Predefined Constants

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. PDO::getAttribute() may be used to
obtain the PDO_ATTR_DRIVER_NAME attribute to check the
driver, if your code can run against multiple drivers.

Read options from the named group from my.cnf or the
file specified with MYSQL_READ_DEFAULT_FILE. This option
is not available if mysqlnd is used, because mysqlnd does not read the mysql
configuration files.

Table of Contents

User Contributed Notes 13 notes

PDO is much better option for calling procedures, views or triggers of mysql 5.x versions from PHP instead of using mysqli extension. Following is a simple demo script which can help anybody on how to call and use mysql procedures through php

This page suggests that the constant PDO::MYSQL_ATTR_FOUND_ROWS was always available (no note "exists as of X.X"), but I found the constant missing on an installation with PHP 5.2. After switching the PHP version to 5.3.27 on the webspace the constant was available.

After spending hours trying to track down why we were getting this error on a new server, after the same code ran fine on other servers, we found the problem to be an old MySQL _client_ library running on our web server, and a latest-version MySQL _server_ running on the database server's box.

Upgraded the MySQL client on the web server to the current revision and the problem went away.

So, I'm trying to get one PHP file to be able to call from two SQL databases at the same time. How can I do that? Or rather, how can I close a connection being made by SqltoAssoc PDO function so I can start a second one with a completely different SQL database?