Edit report at http://bugs.php.net/bug.php?id=51989&edit=1

 ID:               51989
 Updated by:       m...@php.net
 Reported by:      nospam at unclassified dot de
 Summary:          PDO class doesn't connect but reuse open connections
-Status:           Open
+Status:           Bogus
 Type:             Bug
 Package:          *Database Functions
 Operating System: Windows
 PHP Version:      5.3.2

 New Comment:

Well, than it's impossible to help you, and I have to assume the bug is
in your code.



php -r '$p1=new PDO("mysql:dbname=test"); $p2=new
PDO("mysql:dbname=test"); $p1->exec("drop table if exists t1");
$p1->exec("create table t1 (id int auto_increment primary key)");
foreach (array($p1,$p2) as $p) $p->exec("insert into t1(id)
values(NULL)"); foreach (array($p1,$p2) as $p)
var_dump($p->query("SELECT LAST_INSERT_ID()")->fetchAll());'



array(1) {

  [0]=>

  array(2) {

    ["LAST_INSERT_ID()"]=>

    string(1) "1"

    [0]=>

    string(1) "1"

  }

}

array(1) {

  [0]=>

  array(2) {

    ["LAST_INSERT_ID()"]=>

    string(1) "2"

    [0]=>

    string(1) "2"

  }

}



php -r '$p1=new
PDO("mysql:dbname=test",null,null,array(PDO::ATTR_PERSISTENT=>1));
$p2=new
PDO("mysql:dbname=test",null,null,array(PDO::ATTR_PERSISTENT=>1));
$p1->exec("drop table if exists t1"); $p1->exec("create table t1 (id int
auto_increment primary key)"); foreach (array($p1,$p2) as $p)
$p->exec("insert into t1(id) values(NULL)"); foreach (array($p1,$p2) as
$p) var_dump($p->query("SELECT LAST_INSERT_ID()")->fetchAll());'

array(1) {

  [0]=>

  array(2) {

    ["LAST_INSERT_ID()"]=>

    string(1) "2"

    [0]=>

    string(1) "2"

  }

}

array(1) {

  [0]=>

  array(2) {

    ["LAST_INSERT_ID()"]=>

    string(1) "2"

    [0]=>

    string(1) "2"

  }

}


Previous Comments:
------------------------------------------------------------------------
[2010-06-04 09:41:34] nospam at unclassified dot de

Sorry, a script that creates databases and such and also reproduces the
bug in 

under 20 lines of code? That's impossible.

------------------------------------------------------------------------
[2010-06-04 09:38:53] m...@php.net

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.



------------------------------------------------------------------------
[2010-06-03 14:43:58] nospam at unclassified dot de

Description:
------------
The manual says that the PDO class represents a database connection.
Thus I assume that when I instantiate two PDO classes, I get two
database connections. But instead, when using the same connection data,
I do not get a second connection but the first connection is simply
reused. I need a separate connection for logging purposes, it cannot use
the primary connection that's affected by transactions and all such
things.



I do get a separate connection when I connect to "127.0.0.1" instead of
"localhost", which is a different string but the same meaning. This is a
hack though because there are very limited alternatives to define the
same host.

Expected result:
----------------
I expect every PDO instance to actually give me a new connection, at
least when another connection is already in use.

Actual result:
--------------
It gives me the old connection that is used for transactions and such.
My programme doesn't work then. It needs another connection.


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=51989&edit=1

Reply via email to