Changeset 1066

Show
Ignore:
Timestamp:
08/26/08 22:40:52 (3 months ago)
Author:
laurentj
Message:

ticket #672: jdb:getConnection: two connections were created in some case. p=analogue
ticket #671: added the support of a timeout option for the postgresql driver. p=analogue

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0.x/lib/jelix/CREDITS

    r1060 r1066  
    130130 
    131131Laurent Raufaste (aka analogue) 
    132  - patch on postgresql driver (#123
     132 - patches on postgresql driver (#123, #671, #672
    133133 
    134134Rahal 
  • branches/1.0.x/lib/jelix/db/jDb.class.php

    r699 r1066  
    5656 
    5757        $profil = self::getProfil ($name); 
     58 
     59        // we set the name to avoid two connection for a same profil, when it is the default profil 
     60        // and when we call getConnection two times, one with no name and on with the name 
     61        if (!$name) { 
     62            $name = $profil['name']; 
     63        } 
    5864 
    5965        if (!isset ($cnxPool[$name])){ 
  • branches/1.0.x/lib/jelix/plugins/db/pgsql/pgsql.dbconnection.php

    r640 r1066  
    77* @contributor Yannick Le Guédart 
    88* @contributor Laurent Raufaste 
    9 * @copyright  2001-2005 CopixTeam, 2005-2007 Laurent Jouanneau, 2007 Laurent Raufaste 
     9* @copyright  2001-2005 CopixTeam, 2005-2007 Laurent Jouanneau, 2007-2008 Laurent Raufaste 
    1010* This class was get originally from the Copix project (CopixDBConnectionPostgreSQL, Copix 2.3dev20050901, http://www.copix.org) 
    1111* Few lines of code are still copyrighted 2001-2005 CopixTeam (LGPL licence). 
     
    6868        $str = ''; 
    6969 
    70         // on fait une distinction car si host indiqué -> connection TCP/IP, sinon socket unix 
     70        // we do a distinction because if the host is given == TCP/IP connection else unix socket 
    7171        if($this->profil['host'] != '') 
    7272            $str = 'host=\''.$this->profil['host'].'\''.$str; 
    7373 
    74         // Si le port est défini on le rajoute à la chaine de connexion 
    7574        if (isset($this->profil['port'])) { 
    7675            $str .= ' port=\''.$this->profil['port'].'\''; 
    7776        } 
    7877 
    79         // Si le nom de la base de données est spécifié, on le rajoute à la chaine de connexion 
    8078        if ($this->profil['database'] != '') { 
    8179            $str .= ' dbname=\''.$this->profil['database'].'\''; 
    8280        } 
    8381 
    84         // Si le nom d'utilisateur est spécifié, on le rajoute à la chaine de connexion 
    85         // on fait un isset et non une équivalence à chaine vide pour permettre de specifier 
    86         // tout en permettant aussi d'utiliser les variables d'environnements (dans ce cas, ne pas mettre de parametre user dans la conf) 
     82        // we do isset instead of equality test against an empty string, to allow to specify 
     83        // that we want to use configuration set in environment variables 
    8784        if (isset($this->profil['user'])) { 
    8885            $str .= ' user=\''.$this->profil['user'].'\''; 
    8986        } 
    9087 
    91         // Si le mot de passe est spécifié, on le rajoute à la chaine de connexion 
    92         // même remarque que pour login. 
    9388        if (isset($this->profil['password'])) { 
    9489            $str .= ' password=\''.$this->profil['password'].'\''; 
     90        } 
     91 
     92        if (isset($this->profil['timeout']) && $this->profil['timeout'] != '') { 
     93            $str .= ' connect_timeout=\''.$this->profil['timeout'].'\''; 
    9594        } 
    9695 
  • trunk/lib/jelix/CREDITS

    r1061 r1066  
    164164 
    165165Laurent Raufaste (aka analogue) 
    166  - patch on postgresql driver (#123
     166 - patches on postgresql driver (#123, #671, #672
    167167 
    168168Rahal 
  • trunk/lib/jelix/db/jDb.class.php

    r1026 r1066  
    5959 
    6060        $profil = self::getProfil ($name); 
     61 
     62        if (!$name) { 
     63            // we set the name to avoid two connection for a same profil, when it is the default profil 
     64            // and when we call getConnection two times, one with no name and on with the name 
     65            $name = $profil['name']; 
     66        } 
    6167 
    6268        if (!isset ($cnxPool[$name])){ 
  • trunk/lib/jelix/plugins/db/pgsql/pgsql.dbconnection.php

    r1026 r1066  
    77* @contributor Yannick Le Guédart 
    88* @contributor Laurent Raufaste 
    9 * @copyright  2001-2005 CopixTeam, 2005-2007 Laurent Jouanneau, 2007 Laurent Raufaste 
     9* @copyright  2001-2005 CopixTeam, 2005-2007 Laurent Jouanneau, 2007-2008 Laurent Raufaste 
    1010* This class was get originally from the Copix project (CopixDBConnectionPostgreSQL, Copix 2.3dev20050901, http://www.copix.org) 
    1111* Few lines of code are still copyrighted 2001-2005 CopixTeam (LGPL licence). 
     
    6868        $str = ''; 
    6969 
    70         // on fait une distinction car si host indiqué -> connection TCP/IP, sinon socket unix 
     70        // we do a distinction because if the host is given == TCP/IP connection else unix socket 
    7171        if($this->profil['host'] != '') 
    7272            $str = 'host=\''.$this->profil['host'].'\''.$str; 
    7373 
    74         // Si le port est défini on le rajoute à la chaine de connexion 
    7574        if (isset($this->profil['port'])) { 
    7675            $str .= ' port=\''.$this->profil['port'].'\''; 
    7776        } 
    7877 
    79         // Si le nom de la base de données est spécifié, on le rajoute à la chaine de connexion 
    8078        if ($this->profil['database'] != '') { 
    8179            $str .= ' dbname=\''.$this->profil['database'].'\''; 
    8280        } 
    8381 
    84         // Si le nom d'utilisateur est spécifié, on le rajoute à la chaine de connexion 
    85         // on fait un isset et non une équivalence à chaine vide pour permettre de specifier 
    86         // tout en permettant aussi d'utiliser les variables d'environnements (dans ce cas, ne pas mettre de parametre user dans la conf) 
     82        // we do isset instead of equality test against an empty string, to allow to specify 
     83        // that we want to use configuration set in environment variables 
    8784        if (isset($this->profil['user'])) { 
    8885            $str .= ' user=\''.$this->profil['user'].'\''; 
    8986        } 
    9087 
    91         // Si le mot de passe est spécifié, on le rajoute à la chaine de connexion 
    92         // même remarque que pour login. 
    9388        if (isset($this->profil['password'])) { 
    9489            $str .= ' password=\''.$this->profil['password'].'\''; 
     90        } 
     91 
     92        if (isset($this->profil['timeout']) && $this->profil['timeout'] != '') { 
     93            $str .= ' connect_timeout=\''.$this->profil['timeout'].'\''; 
    9594        } 
    9695 
Download in other formats: Unified Diff Zip Archive