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

search for in the

PDO::beginTransaction> <pdf_translate
Last updated: Wed, 16 Mar 2005

view this page in

XCVIII. PDO Functions

Úvod

Varovanie

Toto roz��renie je EXPERIMENT�LNE. Spr�vanie tohto roz��renia -- vr�tane n�zvov jeho funkci� a hoci�oho in�ho zdokumentovan�ho o tomto roz��ren� -- sa mo�e zmeni� bez pov�imnutia v bud�com vydan� PHP. Pou��vajte toto roz��renie na svoje vlastn� riziko.

The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. Note that you cannot perform any database functions using the PDO extension by itself; you must use a database-specific PDO driver to access a database server.

Inštalácia

Windows

Follow the same steps to install and enable the PDO drivers of your choice.

  1. Windows users can download the extension DLL php_pdo.dll as part of the PECL collection binaries from /downloads.php or a more recent version from a PHP 5 PECL Snapshot.

  2. To enable the PDO extension on Windows operating systems, you must add the following line to php.ini:

    extension=php_pdo.dll

  3. Next, choose the other DB specific DLL files and either use dl() to load them at runtime, or enable them in php.ini below pdo_pdo.dll. For example:

    extension=php_pdo.dll
    extension=php_pdo_firebird.dll
    extension=php_pdo_mssql.dll
    extension=php_pdo_mysql.dll
    extension=php_pdo_oci.dll
    extension=php_pdo_oci8.dll
    extension=php_pdo_odbc.dll
    extension=php_pdo_pgsql.dll
    extension=php_pdo_sqlite.dll

    These DLL's should exist in the systems extension_dir.

Linux and UNIX

Due to a bug in the pear installer you should install the PDO package manually using the following steps:

Follow the same steps to install and enable the PDO drivers of your choice.

  1. Download the PDO package to your local machine:

    bash$  wget http://pecl.php.net/get/PDO

  2. Determine your PHP bin directory. If your PHP 5 CLI binary lives at /usr/local/php5/bin/php then the bin dir is /usr/local/php5/bin.

  3. Set your path so that your PHP bin directory is at the front:

    export PATH="/usr/local/php5/bin:$PATH"

  4. Manually build and install the PDO extension:

    bash$ tar xzf PDO-0.2.tgz
    bash$ cd PDO-0.2
    bash$ phpize
    bash$ ./configure
    bash$ make
    bash$ sudo -s
    bash# make install
    bash# echo extension=pdo.so >> /usr/local/php5/lib/php.ini

PDO Drivers

The following drivers currently implement the PDO interface:

Driver nameSupported databases
PDO_DBLIBFreeTDS / Microsoft SQL Server / Sybase
PDO_FIREBIRDFirebird/Interbase 6
PDO_MYSQLMySQL 3.x/4.0
PDO_OCIOracle Call Interface
PDO_ODBCODBC v3 (IBM DB2 and unixODBC)
PDO_PGSQLPostgreSQL
PDO_SQLITESQLite 3.x

Preddefinované triedy

PDO

Represents a connection between PHP and a database server.

Konštruktor

  • PDO - constructs a new PDO object

Metódy

  • beginTransaction - begins a transaction

  • commit - commits a transaction

  • exec - issues an SQL statement and returns the number of affected rows

  • errorCode - retrieves an error code, if any, from the database

  • errorInfo - retrieves an array of error information, if any, from the database

  • getAttribute - retrieves a database connection attribute

  • lastInsertId - retrieves the value of the last row that was inserted into a table

  • prepare - prepares an SQL statement for execution

  • query - issues an SQL statement and returns a result set

  • quote - returns a quoted version of a string for use in SQL statements

  • rollBack - roll back a transaction

  • setAttribute - sets a database connection attribute

PDOStatement

Represents a prepared statement and, after the statement is executed, an associated result set.

Metódy

  • bindColumn - binds a PHP variable to an output column in a result set

  • bindParam - binds a PHP variable to a parameter in the prepared statement

  • columnCount - returns the number of columns in the result set

  • errorCode - retrieves an error code, if any, from the statement

  • errorInfo - retrieves an array of error information, if any, from the statement

  • execute - executes a prepared statement

  • fetch - fetches a row from a result set

  • fetchAll - fetches an array containing all of the rows from a result set

  • fetchSingle - returns the data from the first column in a result set

  • getAttribute - retrieves a PDOStatement attribute

  • getColumnMeta - retrieves metadata for a column in the result set

  • rowCount - returns the number of rows that were affected by the execution of an SQL statement

  • setAttribute - sets a PDOStatement attribute

  • setFetchMode - sets the fetch mode for a PDOStatement

Preddefinované Konštanty

Kon�tanty uveden� ni�ie s� definovan� t�mto roz��ren�m a bud� dostupn� iba ke� roz��renie bolo bu� kompilovan� do PHP alebo dynamicky na��tan� za behu (runtime).

PDO_PARAM_NULL (integer)

Represents the SQL NULL data type.

PDO_PARAM_INT (integer)

Represents the SQL INTEGER data type.

PDO_PARAM_STR (integer)

Represents the SQL CHAR, VARCHAR, or other string data type.

PDO_PARAM_LOB (integer)

Represents the SQL large object data type.

PDO_PARAM_STMT (integer)

PDO_PARAM_INPUT_OUTPUT (integer)

Specifies that the parameter is an INOUT parameter for a stored procedure. You must bitwise-OR this value with an explicit PDO_PARAM_* data type.

PDO_FETCH_LAZY (integer)

Specifies that the fetch method shall return each row as an object with variable names that correspond to the column names returned in the result set. PDO_FETCH_LAZY creates the object variable names as they are accessed.

PDO_FETCH_ASSOC (integer)

Specifies that the fetch method shall return each row as an array indexed by column name as returned in the corresponding result set.

PDO_FETCH_NUM (integer)

Specifies that the fetch method shall return each row as an array indexed by column number as returned in the corresponding result set, starting at column 0.

PDO_FETCH_BOTH (integer)

Specifies that the fetch method shall return each row as an array indexed by both column name and number as returned in the corresponding result set, starting at column 0.

PDO_FETCH_OBJ (integer)

Specifies that the fetch method shall return each row as an object with property names that correspond to the column names returned in the result set.

PDO_FETCH_BOUND (integer)

Specifies that the fetch method shall return TRUE and assign the values of the columns in the result set to the PHP variables to which they were bound with the PDOStatement::bindParam() or PDOStatement::bindColumn() methods.

PDO_FETCH_COLUMN (integer)

Specifies that the fetch method shall return only a single requested column from the next row in the result set.

PDO_FETCH_CLASS (integer)

Specifies that the fetch method shall return a new instance of the requested class, mapping the columns to named properties in the class.

PDO_FETCH_INTO (integer)

Specifies that the fetch method shall update an existing instance of the requested class, mapping the columns to named properties in the class.

PDO_FETCH_FUNC (integer)

PDO_FETCH_GROUP (integer)

PDO_FETCH_UNIQUE (integer)

PDO_FETCH_CLASSTYPE (integer)

PDO_ATTR_AUTOCOMMIT (integer)

PDO_ATTR_PREFETCH (integer)

PDO_ATTR_TIMEOUT (integer)

PDO_ATTR_ERRMODE (integer)

PDO_ATTR_SERVER_VERSION (integer)

PDO_ATTR_CLIENT_VERSION (integer)

PDO_ATTR_SERVER_INFO (integer)

PDO_ATTR_CONNECTION_STATUS (integer)

PDO_ATTR_CASE (integer)

Force column names to a specific case specified by the PDO_CASE_* constants.

PDO_ATTR_CURSOR_NAME (integer)

PDO_ATTR_CURSOR (integer)

PDO_ATTR_ORACLE_NULLS (integer)

PDO_ATTR_PERSISTENT (integer)

PDO_ERRMODE_SILENT (integer)

PDO_ERRMODE_WARNING (integer)

PDO_ERRMODE_EXCEPTION (integer)

PDO_CASE_NATURAL (integer)

Leave column names as returned by the database driver.

PDO_CASE_LOWER (integer)

Force column names to lower case.

PDO_CASE_UPPER (integer)

Force column names to upper case.

PDO_FETCH_ORI_NEXT (integer)

Fetch the next row in the result set. Valid only for scrollable cursors.

PDO_FETCH_ORI_PRIOR (integer)

Fetch the previous row in the result set. Valid only for scrollable cursors.

PDO_FETCH_ORI_FIRST (integer)

Fetch the first row in the result set. Valid only for scrollable cursors.

PDO_FETCH_ORI_LAST (integer)

Fetch the last row in the result set. Valid only for scrollable cursors.

PDO_FETCH_ORI_ABS (integer)

Fetch the requested row by row number from the result set. Valid only for scrollable cursors.

PDO_FETCH_ORI_REL (integer)

Fetch the requested row by relative position from the current position of the cursor in the result set. Valid only for scrollable cursors.

PDO_CURSOR_FWDONLY (integer)

Create a PDOStatement object with a forward-only cursor. This may improve the performance of your application but restricts your PDOStatement object to fetching one row at a time from the result set in a forward direction.

PDO_CURSOR_SCROLL (integer)

Create a PDOStatement object with a scrollable cursor. Pass the PDO_FETCH_ORI_* constants to control the rows fetched from the result set.

PDO_ERR_CANT_MAP (integer)

PDO_ERR_SYNTAX (integer)

PDO_ERR_CONSTRAINT (integer)

PDO_ERR_NOT_FOUND (integer)

PDO_ERR_ALREADY_EXISTS (integer)

PDO_ERR_NOT_IMPLEMENTED (integer)

PDO_ERR_MISMATCH (integer)

PDO_ERR_TRUNCATED (integer)

PDO_ERR_DISCONNECTED (integer)

PDO_ERR_NO_PERM (integer)

PDO_ERR_NONE (string)

Corresponds to SQLSTATE '00000', meaning that the SQL statement was successfully issued with no errors or warnings.

Obsah
PDO::beginTransaction --  Initiates a transaction
PDO::commit --  Commits a transaction
PDO::__construct --  Creates a PDO instance representing a connection to a database
PDO::errorCode --  Fetch the SQLSTATE associated with the last operation on the database handle
PDO::errorInfo --  Fetch extended error information associated with the last operation on the database handle
PDO::exec --  Execute an SQL statement and return the number of affected rows
PDO::getAttribute --  Retrieve a database connection attribute
PDO::lastInsertId --  Returns the ID of the last inserted row
PDO::prepare --  Prepares a statement for execution and returns a statement object
PDO::query --  Executes an SQL statement, returning a result set as a PDOStatement object
PDO::quote --  Quotes a string for use in a query.
PDO::rollBack --  Rolls back a transaction
PDO::setAttribute --  Set an attribute
PDOStatement::bindColumn --  Bind a column to a PHP variable
PDOStatement::bindParam --  Binds a parameter to a the specified variable name
PDOStatement::columnCount --  Returns the number of columns in the result set
PDOStatement::errorCode --  Fetch the SQLSTATE associated with the last operation on the statement handle
PDOStatement::errorInfo --  Fetch extended error information associated with the last operation on the statement handle
PDOStatement::execute --  Executes a prepared statement
PDOStatement::fetch --  Fetches the next row from a result set
PDOStatement::fetchAll --  Returns an array containing all of the result set rows
PDOStatement::fetchSingle --  Returns the first column in the next row of a result set
PDOStatement::getAttribute --  Retrieve a statement attribute
PDOStatement::getColumnMeta --  Returns metadata for a column in a result set
PDOStatement::rowCount --  Returns the number of rows affected by the last SQL statement
PDOStatement::setAttribute --  Set a statement attribute
PDOStatement::setFetchMode --  Set the default fetch mode for this statement


PDO::beginTransaction> <pdf_translate
Last updated: Wed, 16 Mar 2005
 
add a note add a note User Contributed Notes
PDO Functions
metalim
25-May-2007 05:38
From Oracle example:
<?
$stmt->beginTransaction();
$stmt->execute();
$stmt->commit();
?>

PDOStatement has no beginTransaction(), nor commit(). Please fix documentation.
bart at mediawave dot nl
23-May-2007 07:57
It seems MySQL doesn't support scrollable cursors. So unfortunately PDO::CURSOR_SCROLL wont work.
chad 0x40 herballure 0x2e com
17-Apr-2007 06:46
I just discovered that PDOStatement implements Traversable. That means you can use it in foreach loops to iterate over rows:

<?php
$pdo
= new PDO('mysql:dbname=test');
$sth = $pdo->query('SELECT data FROM t1');
foreach(
$sth as $row) {
  echo
$row['data'], "\n";
}
?>
djlopez at gmx dot de
12-Mar-2007 06:04
Note this:

Won't work:
$sth = $dbh->prepare('SELECT name, colour, calories FROM fruit WHERE ? < ?');

THIS WORKS!
$sth = $dbh->prepare('SELECT name, colour, calories FROM fruit WHERE calories < ?');

Parameters cannot be applied on column names!!
smileaf at smileaf dot org
01-Mar-2007 10:57
If you intend on extending PDOStatement and your using
setAttribute(PDO::ATTR_STATEMENT_CLASS, ...)
you must override the __construct() of your PDOStatement class.
failure to do so will result in an error on any PDO::query() call.
Warning: PDO::query() [function.PDO-query]: SQLSTATE[HY000]: General error: user-supplied statement does not accept constructor arguments

Here is a minimum PDO and PDOStatement class
<?php
class Database extends PDO {
    function
__construct($dsn, $username="", $password="", $driver_options=array()) {
       
parent::__construct($dsn,$username,$password, $driver_options);
       
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('DBStatement', array($this)));
    }
}
class
DBStatement extends PDOStatement {
    public
$dbh;
    protected function
__construct($dbh) {
       
$this->dbh = $dbh;
    }
}
?>
php at moechofe dot com
17-Feb-2007 11:52
Simple example to extends PDO

<?php

class connexion extends PDO
{
  public
$query = null;
  public function
prepare( $statement, $driver_options = array() )
  {
   
$this->query = $statement;
    return
parent::prepare( $statement, $driver_options = array() );
  }
  public function
last_query()
  {
    return
$this->query;
  }
}

class
connexion_statement extends PDOStatement
{
  protected
$pdo;
  protected function
__construct($pdo)
  {
    
$this->pdo = $pdo;
  }
 
// return first column of first row
 
public function fetchFirst()
  {
   
$row = $this->fetch( PDO::FETCH_NUM );
    return
$row[0];
  }
 
// real cast number
 
public function fetch( $fetch_style = null, $cursor_orientation = null, $cursor_offset = null )
  {
   
$row = parent::fetch( $fetch_style, $cursor_orientation, $cursor_offset );
    if(
is_array($row) )
      foreach(
$row as $key => $value )
        if(
strval(intval($value)) === $value )
         
$row[$key] = intval($value);
        elseif(
strval(floatval($value)) === $value )
         
$row[$key] = floatval($value);
    return
$row;
  }
 
// permit $prepare->execute( $arg1, $arg2, ... );
 
public function execute( $args = null )
  {
    if(
is_array( $args ) )
      return
parent::execute( $args );
    else
    {
     
$args = func_get_args();
      return eval(
'return parent::execute( $args );' );
    }
  }
  public function
last_query()
  {
    return
$this->pdo->last_query();
  }
}

$pdo = new connexion( ... );
$pdo->setAttribute( PDO::ATTR_STATEMENT_CLASS, array( 'connexion_statement', array($pdo) ) );

?>
katzke at gmail dot com
08-Jan-2007 12:38
It doesn't seem at this time that there's a practical solution (besides creating multiple PDO objects and therefore DB connections) to accessing and switching between multiple databases -- as with the mysql_select_db function.
webform at aouie dot website
27-Sep-2006 11:38
If you use $dbh = new PDO('pgsql:host=localhost;dbname=test_basic01', $user, $pass); and you get the following error:
PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[08006] [7] could not connect to server: Connection refused\n\tIs the server running on host "localhost" and accepting\n\tTCP/IP connections on port 5432?'
then as pointed out under pg_connect at: http://www.php.net/manual/en/function.pg-connect.php#38291
******
you should try to leave the host= and port= parts out of the connection string. This sounds strange, but this is an "option" of Postgre. If you have not activated the TCP/IP port in postgresql.conf then postgresql doesn't accept any incoming requests from an TCP/IP port. If you use host= in your connection string you are going to connect to Postgre via TCP/IP, so that's not going to work. If you leave the host= part out of your connection string you connect to Postgre via the Unix domain sockets, which is faster and more secure, but you can't connect with the database via any other PC as the localhost.
******
Sincerely,
Aouie
djlopez at gmx dot de
30-Aug-2006 02:56
Please note this:

Won't work:
$sth = $dbh->prepare('SELECT name, colour, calories FROM ?  WHERE calories < ?');

THIS WORKS!
$sth = $dbh->prepare('SELECT name, colour, calories FROM fruit WHERE calories < ?');

The parameter cannot be applied on table names!!
paulius_k at yahoo dot com
25-Jul-2006 08:42
If you need to get Output variable from MSSQL stored procedure, try this :

-- PROCEDURE
CREATE PROCEDURE spReturn_Int @err int OUTPUT
AS
SET @err = 11
GO

$sth = $dbh->prepare("EXECUTE spReturn_Int ?");
$sth->bindParam(1, $return_value, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT);
$sth->execute();
print "procedure returned $return_value\n";
webograph at eml dot cc
13-Jul-2006 04:02
pdo doesn't care about charsets. if you want to have your connection in unicode / utf-8 or any other encoding, you'll have to tell your database, for example using $dbh->exec('SET CHARACTER SET utf8') (mysql).
nicolas at serpe dot org
21-May-2006 12:36
I use PDO with the ODBC driver to query stored procedures in a MS SQL Server 2005 Database under Windows XP Professional with IIS 5 and PHP 5.1.4. You may have the same problems with a different configuration.

I experienced 2 very time consuming errors:

1. The first one is when you return the result of a SELECT query, and you get the following clueless message:
>>> Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[24000]: Invalid cursor state: 0 [Microsoft][SQL Native Client]Invalid cursor state (SQLFetchScroll[0] at ext\pdo_odbc\odbc_stmt.c:372)' in (YOUR_TRACE_HERE) <<<
Your exact message may be different, the part to pay attention to is "Invalid cursor state".

-> I found that I had this error because I didn't include "SET NOCOUNT ON" in the *body* of the stored procedure. By default the server returns a special piece of information along with the results, indicating how many rows were affected by the stored procedure, and that's not handled by PDO.

2. The second error I had was:
>>> Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[22003]: Numeric value out of range: 0 [Microsoft][SQL Native Client]Numeric value out of range (SQLFetchScroll[0] at ext\pdo_odbc\odbc_stmt.c:372)' in (YOUR_TRACE_HERE) <<<
Another meaningless error "Numeric value out of range"...

-> I was actually returning a date datatype (datetime or smalldatetime) "as is", that is, without converting it to varchar before including it in the result set... I don't know if PDO is responsible for converting it to a PHP datatype, but it doesn't. Convert it before it reaches PHP.
pokojny at radlight dot com
23-Apr-2006 08:50
I wanted to extend PDO class to store statistics of DB usage, and I faced some problems. I wanted to count number of created statements and number of their executings. So PDOStatement should have link to PDO that created it and stores the statistical info. The problem was that I didn't knew how PDO creates PDOStatement (constructor parameters and so on), so I have created these two classes:

<?php
/**
 * PHP Document Object plus
 *
 * PHP Document Object plus is library with functionality of PDO, entirely written
 * in PHP, so that developer can easily extend it's classes with specific functionality,
 * such as providing database usage statistics implemented in v1.0b
 *
 * @author Peter Pokojny
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 */
   
class PDOp {
        protected
$PDO;
        public
$numExecutes;
        public
$numStatements;
        public function
__construct($dsn, $user=NULL, $pass=NULL, $driver_options=NULL) {
           
$this->PDO = new PDO($dsn, $user, $pass, $driver_options);
           
$this->numExecutes = 0;
           
$this->numStatements = 0;
        }
        public function
__call($func, $args) {
            return
call_user_func_array(array(&$this->PDO, $func), $args);
        }
        public function
prepare() {
           
$this->numStatements++;
           
           
$args = func_get_args();
           
$PDOS = call_user_func_array(array(&$this->PDO, 'prepare'), $args);
           
            return new
PDOpStatement($this, $PDOS);
        }
        public function
query() {
           
$this->numExecutes++;
           
$this->numStatements++;
           
           
$args = func_get_args();
           
$PDOS = call_user_func_array(array(&$this->PDO, 'query'), $args);
           
            return new
PDOpStatement($this, $PDOS);
        }
        public function
exec() {
           
$this->numExecutes++;
           
           
$args = func_get_args();
            return
call_user_func_array(array(&$this->PDO, 'exec'), $args);
        }
    }
    class
PDOpStatement implements IteratorAggregate {
        protected
$PDOS;
        protected
$PDOp;
        public function
__construct($PDOp, $PDOS) {
           
$this->PDOp = $PDOp;
           
$this->PDOS = $PDOS;
        }
        public function
__call($func, $args) {
            return
call_user_func_array(array(&$this->PDOS, $func), $args);
        }
        public function
bindColumn($column, &$param, $type=NULL) {
            if (
$type === NULL)
               
$this->PDOS->bindColumn($column, $param);
            else
               
$this->PDOS->bindColumn($column, $param, $type);
        }
        public function
bindParam($column, &$param, $type=NULL) {
            if (
$type === NULL)
               
$this->PDOS->bindParam($column, $param);
            else
               
$this->PDOS->bindParam($column, $param, $type);
        }
        public function
execute() {
           
$this->PDOp->numExecutes++;
           
$args = func_get_args();
            return
call_user_func_array(array(&$this->PDOS, 'execute'), $args);
        }
        public function
__get($property) {
            return
$this->PDOS->$property;
        }
        public function
getIterator() {
            return
$this->PDOS;
        }
   }
?>

Classes have properties with original PDO and PDOStatement objects, which are providing the functionality to PDOp and PDOpStatement.
From outside, PDOp and PDOpStatement look like PDO and PDOStatement, but also are providing wanted info.
keyvez at hotmail dot com
09-Mar-2006 12:49
PDO doesn't return OUTPUT params from mssql stored procedures

/* Stored Procedure Create Code: */
/*
CREATE PROCEDURE p_sel_all_termlength @err INT OUTPUT AS
SET @err = 2627
*/

/* PHP Code: */
<?php
    $Link
= new PDO('mssql:host=sqlserver;dbname=database', 'username',
'password');
   
   
$ErrorCode = 0;
   
   
$Stmt = $Link->prepare('p_sel_all_termlength ?');
   
$Stmt->bindParam(1,$ErrorCode,PDO::PARAM_INT,4);
   
$Stmt->execute();
    echo
"Error = " . $ErrorCode . "\n";
?>

/* PHP Output:
Error = 0
*/
www.navin.biz
19-Feb-2006 10:16
Below is an example of extending PDO & PDOStatement classes:

<?php

class Database extends PDO
{
    function
__construct()
    {
       
parent::__construct('mysql:dbname=test;host=localhost', 'root', '');
       
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('DBStatement', array($this)));
    }
}

class
DBStatement extends PDOStatement
{
    public
$dbh;

    protected function
__construct($dbh)
    {
       
$this->dbh = $dbh;
       
$this->setFetchMode(PDO::FETCH_OBJ);
    }
   
    public function
foundRows()
    {
       
$rows = $this->dbh->prepare('SELECT found_rows() AS rows', array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE));
       
$rows->execute();
       
$rowsCount = $rows->fetch(PDO::FETCH_OBJ)->rows;
       
$rows->closeCursor();
        return
$rowsCount;
    }
}

?>
Dariusz Kielar
12-Feb-2006 10:50
I found a nice pdo modification written in php called Open Power Driver. It has identical API with the original, but allows you to cache query results: http://www.openpb.net/opd.php
shaolin at adf dot nu
07-Feb-2006 06:18
If your having problems re-compiling PHP with PDO as shared module try this.

--enable-pdo=shared
--with-pdo-mysql=shared,/usr/local/mysql
--with-sqlite=shared
--with-pdo-sqlite=shared

1. If PDO is built as a shared modules, all PDO drivers must also be
built as shared modules.
2. If ext/pdo_sqlite is built as a shared module, ext/sqlite must also
be built as a shared module.
3. In the extensions entries, if ext/pdo_sqlite is built as a shared
module, php.ini must specify pdo_sqlite first, followed by sqlite.
tomasz dot wasiluk at gmail dot com
01-Jan-2006 04:09
Watch out for putting spaces in the DSN
mysql:host=localhost;dbname=test works
mysql: host = localhost; dbname=test works
mysql: host = localhost; dbname = test doesn't work...
Matthias Leuffen
04-Dec-2005 01:36
Hi there,

because of ZDE 5.0 and other PHP-IDEs do not seem to support PDO from PHP5.1 in code-completion-database yet, I wrote a code-completion alias for the PDO class.
NOTE: This Class has no functionality and should be only included to your IDE-Project but NOT(!) to your application.

<?php
/**
 * This is a Code-Completion only file
 * (For use with ZDE or other IDEs)
 *
 * Do NOT include() or require() this to your code
 *
 * @author Matthias Leuffen
 */

   
class PDO {
       
       
/**
         * Error Constants
         *
         */
       
const ERR_ALREADY_EXISTS = 0;
        const
ERR_CANT_MAP = 0;
        const
ERR_NOT_FOUND = 0;
        const
ERR_SYNTAX = 0;
        const
ERR_CONSTRAINT = 0;
        const
ERR_MISMATCH = 0;
        const
ERR_DISCONNECTED = 0;
        const
ERR_NONE = 0;

       
/**
         * Attributes (to use in PDO::setAttribute() as 1st Parameter)
         *
         */
       
const ATTR_ERRMODE = 0;
        const
ATTR_TIMEOUT = 0;
        const
ATTR_AUTOCOMMIT = 0;
        const
ATTR_PERSISTENT = 0;

       
// Values for ATTR_ERRMODE
       
const ERRMODE_EXCEPTION = 0;
        const
ERRMODE_WARNING = 0;

        const
FETCH_ASSOC = 0;
        const
FETCH_NUM = 0;
        const
FETCH_OBJ = 0;
       
        public function
__construct($uri, $user, $pass, $optsArr) {
        }
       
       
/**
         * Prepare Statement: Returns PDOStatement
         *
         * @param string $prepareString
         * @return PDOStatement
         */
       
public function prepare ($prepareString) {
        }
        public function
query ($queryString) {
        }
        public function
quote ($input) {
        }
        public function
exec ($statement) {
        }
        public function
lastInsertId() {
        }
        public function
beginTransaction () {
        }
        public function
commit () {
        }
        public function
rollBack () {
        }
        public function
errorCode () {
        }
        public function
errorInfo () {
        }       
    }
   
    class
PDOStatement {
       
        public function
bindValue ($no, $value) {
        }
        public function
fetch () {
        }
        public function
nextRowset () {
        }
        public function
execute() {
        }
        public function
errorCode () {
        }
        public function
errorInfo () {
        }
        public function
rowCount () {
        }
        public function
setFetchMode ($mode) {
        }
        public function
columnCount () {
        }
    }
ng4rrjanbiah at rediffmail dot com
15-Mar-2005 10:53
Some useful links on PDO:
1. PDO Wiki ( http://wiki.cc/php/PDO )
2. Introducing PHP Data Objects ( http://netevil.org/downloads/Introducing-PDO.ppt ), [226 KB], Wez Furlong, 2004-09-24
3. The PHP 5 Data Object (PDO) Abstraction Layer and Oracle ( http://www.oracle.com/technology/pub/articles/php_experts/otn_pdo_oracle5.html ), [60.85 KB], Wez Furlong, 2004-07-28
4. PDO - Why it should not be part of core PHP! ( http://www.akbkhome.com/blog.php/View/55/ ), Critical review, [38.63 KB], Alan Knowles, 2004-10-22

HTH,
R. Rajesh Jeba Anbiah

PDO::beginTransaction> <pdf_translate
Last updated: Wed, 16 Mar 2005
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites