From af16245ab076ea3da9477dd3fda29cc0b83ee88b Mon Sep 17 00:00:00 2001 From: nate Date: Tue, 3 Jun 2008 02:26:40 +0000 Subject: [PATCH] Fixing persistent connection handling in Postgres driver, updating fixture with unique index name, removing support for deprecated 'connect' key in database drivers, closes #4773 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7097 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/model/datasources/dbo/dbo_mysql.php | 2 +- cake/libs/model/datasources/dbo/dbo_postgres.php | 14 ++++++++++---- cake/tests/fixtures/stories_tag_fixture.php | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index a42ad9b16..8a9b548a1 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -107,7 +107,7 @@ class DboMysql extends DboSource { $connect = $config['connect']; $this->connected = false; - if (!$config['persistent'] || $config['connect'] === 'mysql_connect') { + if (!$config['persistent']) { $this->connection = mysql_connect($config['host'] . ':' . $config['port'], $config['login'], $config['password'], true); } else { $this->connection = $connect($config['host'] . ':' . $config['port'], $config['login'], $config['password']); diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 8311e5e87..145f627bb 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -107,8 +107,14 @@ class DboPostgres extends DboSource { */ function connect() { $config = $this->config; - $connect = $config['connect']; - $this->connection = $connect("host='{$config['host']}' port='{$config['port']}' dbname='{$config['database']}' user='{$config['login']}' password='{$config['password']}'"); + $conn = "host='{$config['host']}' port='{$config['port']}' dbname='{$config['database']}' "; + $conn .= "user='{$config['login']}' password='{$config['password']}'"; + + if (!$config['persistent']) { + $this->connection = pg_connect($conn, PGSQL_CONNECT_FORCE_NEW); + } else { + $this->connection = pg_pconnect($conn); + } $this->connected = false; if ($this->connection) { @@ -604,8 +610,8 @@ class DboPostgres extends DboSource { $out = preg_replace('/integer\([0-9]+\)/', 'integer', parent::buildColumn($column)); $out = str_replace('integer serial', 'serial', $out); - if (strpos($column, 'DEFAULT DEFAULT')) { - if ($column['null']) { + if (strpos($out, 'DEFAULT DEFAULT')) { + if (isset($column['null']) && $column['null']) { $out = str_replace('DEFAULT DEFAULT', 'DEFAULT NULL', $out); } elseif (in_array($column['type'], array('integer', 'float'))) { $out = str_replace('DEFAULT DEFAULT', 'DEFAULT 0', $out); diff --git a/cake/tests/fixtures/stories_tag_fixture.php b/cake/tests/fixtures/stories_tag_fixture.php index 2361bc530..068549fd3 100644 --- a/cake/tests/fixtures/stories_tag_fixture.php +++ b/cake/tests/fixtures/stories_tag_fixture.php @@ -49,7 +49,7 @@ class StoriesTagFixture extends CakeTestFixture { var $fields = array( 'story' => array('type' => 'integer', 'null' => false), 'tag_id' => array('type' => 'integer', 'null' => false), - 'indexes' => array('UNIQUE_TAG' => array('column'=> array('story', 'tag_id'), 'unique'=>1)) + 'indexes' => array('UNIQUE_STORY_TAG' => array('column'=> array('story', 'tag_id'), 'unique'=>1)) ); var $records = array( array('story' => 1, 'tag_id' => 1)