developer.jelix.org is not used any more and exists only for
history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.
Opened 14 years ago
Closed 14 years ago
#122 closed enhancement (invalid)
proposed patch to jDbConnection.postgresql.class.php
Reported by: | klando | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | jelix:db | Version: | 1.0 beta1 |
Severity: | major | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Documentation needed: | ||
Hosting Provider: | Php version: |
Description
Add a test on password (!= )
Use an array to implode vs $str
Index: jDbConnection.postgresql.class.php =================================================================== --- jDbConnection.postgresql.class.php (revision 373) +++ jDbConnection.postgresql.class.php (working copy) @@ -63,18 +63,25 @@ protected function _connect (){ $funcconnect= ($this->profil['persistent'] ? 'pg_pconnect':'pg_connect'); - $str = 'dbname=\''.$this->profil['database'].'\' user=\''.$this->profil['user'].'\' password=\''.$this->profil['password'].'\''; + $arr_connect = array(); + $arr_connect[] = "dbname='{$this->profil['database']}'"; + $arr_connect[] = "user='{$this->profil['user']}'"; + // Si le password est défini on le rajoute à la chaine de connexion + if ($this->profil['password'] != '') { + $arr_connect[] = "password='{$this->profil['password']}'"; + } // on fait une distinction car si host indiqué -> connection TCP/IP, sinon socket unix - if($this->profil['host'] != '') - $str = 'host=\''.$this->profil['host'].'\' '.$str; + if($this->profil['host'] != '') { + $arr_connect[] = "host='{$this->profil['host']}'"; + } // Si le port est défini on le rajoute à la chaine de connexion if (isset($this->profil['port'])) { - $str .= ' port=\''.$this->profil['port'].'\''; + $arr_connect[] = "port='{$this->profil['port']}'"; } - if($cnx=@$funcconnect ($str)){ + if($cnx=@$funcconnect (implode(' ',$arr_connect))) { if(isset($this->profil['force_encoding']) && $this->profil['force_encoding'] == true && isset($this->_charsets[$GLOBALS['gJConfig']->defaultCharset])){ pg_set_client_encoding($cnx, $this->_charsets[$GLOBALS['gJConfig']->defaultCharset]);
Change History (4)
comment:1 Changed 14 years ago by laurentj
- Component changed from jelix to jelix:db
comment:2 Changed 14 years ago by laurentj
- Reporter changed from anonymous to klando
comment:3 Changed 14 years ago by laurentj
le principal souci auquel repond en parti ce patch est de pouvoir utiliser les variables d'environnement pour postgresql. analogue a donné un patch un peu plus complet, cf ticket #123
Faire des tests de performances, pour savoir si l'utilisation d'un tableau est plus performante que la concatenation simple de chaines.
comment:4 Changed 14 years ago by laurentj
- Resolution set to invalid
- Status changed from new to closed
d'aprés des tests avec xdebug, la version avec tableau est 4 fois plus gourmandes en temps d'exécution que la version actuelle avec concatenation de chaine. Ce patch ne sera donc pas retenu (mais le problème du password corrigé)
Note: See
TracTickets for help on using
tickets.
je ne vois pas l'interet du patch... je doute fort que l'usage d'un tableau apporte un plus dans le cas présent. Et surtout que l'histoire du password est corrigé déjà : cf ticket #121