IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

CodeIgniter PHP Discussion :

Se connecter à plusieurs bdd


Sujet :

CodeIgniter PHP

  1. #1
    Candidat au Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    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 : 2
    Points
    2
    Par défaut 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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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...

  2. #2
    Membre à l'essai
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2011
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juillet 2011
    Messages : 44
    Points : 19
    Points
    19
    Par défaut
    Tu as quoi comme erreur ?

    Pour ma part voici mon database.php :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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 */

Discussions similaires

  1. Réponses: 2
    Dernier message: 11/05/2017, 16h05
  2. Connecter plusieurs BDD
    Par thibaut06 dans le forum Requêtes
    Réponses: 6
    Dernier message: 06/10/2007, 20h25
  3. [SAGE ODBC] Comment connecter une BDD ?
    Par aqwz dans le forum Autres SGBD
    Réponses: 8
    Dernier message: 14/09/2006, 10h00
  4. [debutant] connection à une BDD MySQL
    Par Golork dans le forum Bases de données
    Réponses: 1
    Dernier message: 11/03/2005, 16h51
  5. [Débutant] Tester une connection sur bdd
    Par lando dans le forum Servlets/JSP
    Réponses: 3
    Dernier message: 03/09/2003, 14h37

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo