mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
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
This commit is contained in:
parent
93864f608a
commit
af16245ab0
3 changed files with 12 additions and 6 deletions
|
@ -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']);
|
||||
|
|
|
@ -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);
|
||||
|
|
2
cake/tests/fixtures/stories_tag_fixture.php
vendored
2
cake/tests/fixtures/stories_tag_fixture.php
vendored
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue