Précédent   Forum du club des développeurs et IT Pro > PHP > Bibliothèques et frameworks
Bibliothèques et frameworks Forum d'entraide sur les frameworks, templates, bibliothèques de code (PDFLib, eZPdf, JpGraph, Artichow, PEAR, etc). Avant de poster : FAQ bibliothèques, toutes les FAQ PHP et cours bibliothèques
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 25/10/2012, 11h50   #1
colonel_moutarde
Invité de passage
 
Homme
Développeur Web
Inscription : octobre 2012
Messages : 2
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : octobre 2012
Messages : 2
Points : 1
Points : 1
Par défaut [codeigniter] se connecter à plusieurs bdd

salut,
Je découvre Codeingiter et j'aimerai me connecter à plusieurs bdd en simultané.
voici mon code php extrait de "database.php"
Code : PHP - Sélectionner

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
$active_group = 'default';
$active_record = TRUE;
 
$db['default']['hostname'] = 'serveur';
$db['default']['username'] = 'mysql';
$db['default']['password'] = 'xxxxxx';
$db['default']['database'] = 'xxxxxx';
$db['default']['dbdriver'] = 'mysqli';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
 
 
 
$active_group = 'fbird';
$active_record = TRUE;
 
$db['fbird']['hostname'] = 'serveur';
$db['fbird']['username'] = 'xxxxxx';
$db['fbird']['password'] = 'xxxxx';
$db['fbird']['database'] = 'xxxxxxxx.dba'; //developpement
//$db['fbird']['database'] = "xxxxxxxxxxxxxxxxxxx.dba"; //production
$db['fbird']['dbdriver'] = 'firebird';
$db['fbird']['port'] = 3050;
 
/* End of file database.php */
/* Location: ./application/config/database.php */


Bien sûr ce que vous avez sous les yeux ne fonctionne pas et je tiens à préciser que j'ai rajouté la bibliothèque firebird avant de vous contacter.

Jusqu’à la ligne 22 tous va bien après, c'est la cata...
colonel_moutarde est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/11/2012, 20h58   #2
deathart
Invité régulier
 
Homme Louis Brabant
Inscription : juillet 2011
Messages : 43
Détails du profil
Informations personnelles :
Nom : Homme Louis Brabant
Localisation : France, Nord (Nord Pas de Calais)

Informations forums :
Inscription : juillet 2011
Messages : 43
Points : 5
Points : 5
Envoyer un message via MSN à deathart Envoyer un message via Skype™ à deathart
Tu as quoi comme erreur ?

Pour ma part voici mon database.php :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the 'Database Connection'
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
|	['hostname'] The hostname of your database server.
|	['username'] The username used to connect to the database
|	['password'] The password used to connect to the database
|	['database'] The name of the database you want to connect to
|	['dbdriver'] The database type. ie: mysql.  Currently supported:
				 mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
|	['dbprefix'] You can add an optional prefix, which will be added
|				 to the table name when using the  Active Record class
|	['pconnect'] TRUE/FALSE - Whether to use a persistent connection
|	['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
|	['cache_on'] TRUE/FALSE - Enables/disables query caching
|	['cachedir'] The path to the folder where cache files should be stored
|	['char_set'] The character set used in communicating with the database
|	['dbcollat'] The character collation used in communicating with the database
|				 NOTE: For MySQL and MySQLi databases, this setting is only used
| 				 as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
|				 (and in table creation queries made with DB Forge).
| 				 There is an incompatibility in PHP with mysql_real_escape_string() which
| 				 can make your default vulnerable to SQL injection if you are using a
| 				 multi-byte character set and are running versions lower than these.
| 				 defaults using Latin-1 or UTF-8 database character set and collation are unaffected.
|	['swap_pre'] A default table prefix that should be swapped with the dbprefix
|	['autoinit'] Whether or not to automatically initialize the database.
|	['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
|							- good for ensuring strict SQL while developing
|
| The $active_group variable lets you choose which connection group to
| make active.  By default there is only one group (the 'default' group).
|
| The $active_record variables lets you determine whether or not to load
| the active record class
*/
 
$active_group = 'default';
$active_record = TRUE;
 
$db['default']['hostname'] = '127.0.0.1';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'shadows1_site';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
 
/*
$db['char']['hostname'] = 'localhost';
$db['char']['username'] = 'root';
$db['char']['password'] = '';
$db['char']['database'] = 'characters';
$db['char']['dbdriver'] = 'mysql';
$db['char']['dbprefix'] = '';
$db['char']['pconnect'] = TRUE;
$db['char']['db_debug'] = TRUE;
$db['char']['cache_on'] = FALSE;
$db['char']['cachedir'] = '';
$db['char']['char_set'] = 'utf8';
$db['char']['dbcollat'] = 'utf8_general_ci';
$db['char']['swap_pre'] = '';
$db['char']['autoinit'] = TRUE;
$db['char']['stricton'] = FALSE;
 
$db['realmd']['hostname'] = 'localhost';
$db['realmd']['username'] = 'root';
$db['realmd']['password'] = '';
$db['realmd']['database'] = 'auth';
$db['realmd']['dbdriver'] = 'mysql';
$db['realmd']['dbprefix'] = '';
$db['realmd']['pconnect'] = TRUE;
$db['realmd']['db_debug'] = TRUE;
$db['realmd']['cache_on'] = FALSE;
$db['realmd']['cachedir'] = '';
$db['realmd']['char_set'] = 'utf8';
$db['realmd']['dbcollat'] = 'utf8_general_ci';
$db['realmd']['swap_pre'] = '';
$db['realmd']['autoinit'] = TRUE;
$db['realmd']['stricton'] = FALSE;
*/
 
 
$db['char']['hostname'] = '127.0.0.1';
$db['char']['username'] = 'root';
$db['char']['password'] = '';
$db['char']['database'] = 'characters';
$db['char']['dbdriver'] = 'mysql';
$db['char']['dbprefix'] = '';
$db['char']['pconnect'] = TRUE;
$db['char']['db_debug'] = TRUE;
$db['char']['cache_on'] = FALSE;
$db['char']['cachedir'] = '';
$db['char']['char_set'] = 'utf8';
$db['char']['dbcollat'] = 'utf8_general_ci';
$db['char']['swap_pre'] = '';
$db['char']['autoinit'] = TRUE;
$db['char']['stricton'] = FALSE;
 
$db['world']['hostname'] = '127.0.0.1';
$db['world']['username'] = 'root';
$db['world']['password'] = '';
$db['world']['database'] = 'world';
$db['world']['dbdriver'] = 'mysql';
$db['world']['dbprefix'] = '';
$db['world']['pconnect'] = TRUE;
$db['world']['db_debug'] = TRUE;
$db['world']['cache_on'] = FALSE;
$db['world']['cachedir'] = '';
$db['world']['char_set'] = 'utf8';
$db['world']['dbcollat'] = 'utf8_general_ci';
$db['world']['swap_pre'] = '';
$db['world']['autoinit'] = TRUE;
$db['world']['stricton'] = FALSE;
 
$db['realmd']['hostname'] = '127.0.0.1';
$db['realmd']['username'] = 'root';
$db['realmd']['password'] = '';
$db['realmd']['database'] = 'auth';
$db['realmd']['dbdriver'] = 'mysql';
$db['realmd']['dbprefix'] = '';
$db['realmd']['pconnect'] = TRUE;
$db['realmd']['db_debug'] = TRUE;
$db['realmd']['cache_on'] = FALSE;
$db['realmd']['cachedir'] = '';
$db['realmd']['char_set'] = 'utf8';
$db['realmd']['dbcollat'] = 'utf8_general_ci';
$db['realmd']['swap_pre'] = '';
$db['realmd']['autoinit'] = TRUE;
$db['realmd']['stricton'] = FALSE;
 
 
/* End of file database.php */
/* Location: ./application/config/database.php */
deathart est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 21h27.


 
 
 
 
Partenaires

Hébergement Web