Subversion Repositories Applications.framework

Rev

Rev 420 | Rev 429 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 420 Rev 427
Line 15... Line 15...
15
 * @author		Aurélien PERONNET <aurelien@tela-botanica.org>
15
 * @author		Aurélien PERONNET <aurelien@tela-botanica.org>
16
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
16
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
17
 * @copyright	Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
17
 * @copyright	Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
18
 * @license	http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
18
 * @license	http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
19
 * @license	http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
19
 * @license	http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
20
 * @version	$Id: Bdd.php 420 2013-04-10 10:22:46Z gduche $
20
 * @version	$Id: Bdd.php 427 2013-06-28 07:53:51Z raphael $
21
 * @link		/doc/framework/
21
 * @link		/doc/framework/
22
 */
22
 */
23
class Bdd {
23
class Bdd {
24
	/** Constante stockant le squelette du message en cas d'erreur de requête sql. */
24
	/** Constante stockant le squelette du message en cas d'erreur de requête sql. */
25
	const ERREUR_REQUETE_TPL = 'Requête echec.\nFichier : %s.\nLigne : %s.\nMessage : %s.\nRequête : %s';
25
	const ERREUR_REQUETE_TPL = 'Requête echec.\nFichier : %s.\nLigne : %s.\nMessage : %s.\nRequête : %s';
Line 92... Line 92...
92
		$this->type = Config::get('bdd_protocole');
92
		$this->type = Config::get('bdd_protocole');
93
		$this->hote = Config::get('bdd_serveur');
93
		$this->hote = Config::get('bdd_serveur');
94
		$this->bdd_nom = Config::get('bdd_nom');
94
		$this->bdd_nom = Config::get('bdd_nom');
95
		$this->utilisateur = Config::get('bdd_utilisateur');
95
		$this->utilisateur = Config::get('bdd_utilisateur');
96
		$this->pass = Config::get('bdd_mot_de_passe');
96
		$this->pass = Config::get('bdd_mot_de_passe');
-
 
97
		$this->dsn = Config::get('bdd_dsn');
Line 97... Line 98...
97
		
98
		
Line -... Line 99...
-
 
99
		$this->encodage = Config::get('bdd_encodage');
98
		$this->encodage = Config::get('bdd_encodage');
100
 
99
 
101
		if (!$this->dsn) {
100
		if ($this->type == 'sqlite' || $this->type == 'sqlite2') {
102
			if ($this->type == 'sqlite' || $this->type == 'sqlite2') {
101
			$this->dsn = $this->type.':'.$this->hote;
103
				$this->dsn = $this->type.':'.$this->hote;
-
 
104
			} else {
102
		} else {
105
				$this->dsn = $this->type.':dbname='.$this->bdd_nom.';host='.$this->hote;
103
			$this->dsn = $this->type.':dbname='.$this->bdd_nom.';host='.$this->hote;
106
			}
104
		}
107
		}
Line 105... Line 108...
105
		$this->initialiserProtocole();
108
		$this->initialiserProtocole();
Line 145... Line 148...
145
					} catch (PDOException $e) {
148
					} catch (PDOException $e) {
146
						$e = sprintf(self::ERREUR_CONNEXION_TPL, $e->getMessage());
149
						$e = sprintf(self::ERREUR_CONNEXION_TPL, $e->getMessage());
147
						trigger_error($e, E_USER_WARNING);
150
						trigger_error($e, E_USER_WARNING);
148
					}
151
					}
149
					if ($this->encodage != null && $this->type == 'mysql') {
152
					if ($this->encodage != null && $this->type == 'mysql') {
150
						$this->requeter("SET names '".$this->encodage."'");
153
						$this->connexion->query("SET names '".$this->encodage."'");
151
					} else if ($this->type == 'sqlite') {
154
					} else if ($this->type == 'sqlite') {
152
						$this->requeter("PRAGMA case_sensitive_like = false");
155
						$this->connexion->query("PRAGMA case_sensitive_like = false");
153
					}
156
					}
154
					break;
157
					break;
155
				case self::ABSTRACTION_MYSQL :
158
				case self::ABSTRACTION_MYSQL :
156
					$this->connexion = mysql_connect($this->hote, $this->utilisateur, $this->pass);
159
					$this->connexion = mysql_connect($this->hote, $this->utilisateur, $this->pass);
157
					if ($this->connexion !== false) {
160
					if ($this->connexion !== false) {