Skip to content

Commit 872a2f8

Browse files
committed
Change default for autoconnect to true
1 parent e261a8b commit 872a2f8

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ RDBMS support for the XP Framework: MySQL, Sybase, MSSQL, PostgreSQL, SQLite3, I
33

44
## ?.?.? / ????-??-??
55

6+
* Changed the default for *autoconnect* to true, that is, if it is omitted
7+
from the DSN, it will automatically connect. If the driver should not
8+
automatically connect, add `?autoconnect=0` to the DSN.
9+
(@thekid)
10+
611
## 6.2.2 / 2015-06-01
712

813
* Changed MySQL userland protocol to handle case when MySQL server disconnects

src/main/php/rdbms/DBConnection.class.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ abstract class DBConnection extends Observable {
3030
public function __construct($dsn) {
3131
$this->dsn= $dsn;
3232
$this->flags= $dsn->getFlags();
33+
if (!$this->dsn->url->hasParam('autoconnect')) {
34+
$this->flags |= DB_AUTOCONNECT;
35+
}
3336
$this->setTimeout($dsn->getProperty('timeout', 0)); // 0 means no timeout
3437

3538
// Keep this for BC reasons

src/test/php/rdbms/unittest/DBTest.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class DBTest extends TestCase {
1515
* Setup function
1616
*/
1717
public function setUp() {
18-
$this->conn= DriverManager::getConnection('mock://mock/MOCKDB');
18+
$this->conn= DriverManager::getConnection('mock://mock/MOCKDB?autoconnect=0');
1919
$this->assertEquals(0, $this->conn->flags & DB_AUTOCONNECT);
2020
}
2121

0 commit comments

Comments
 (0)