Publicité
+ Répondre à la discussion
Affichage des résultats 1 à 2 sur 2
  1. #1
    Invité de passage
    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 : 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...

  2. #2
    Invité régulier
    Homme Profil pro Louis Brabant
    Inscrit en
    juillet 2011
    Messages
    44
    Détails du profil
    Informations personnelles :
    Nom : Homme Louis Brabant
    Localisation : France, Nord (Nord Pas de Calais)

    Informations forums :
    Inscription : juillet 2011
    Messages : 44
    Points : 5
    Points
    5

    Par défaut

    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 */

Liens sociaux

Règles de messages

  • Vous ne pouvez pas créer de nouvelles discussions
  • Vous ne pouvez pas envoyer des réponses
  • Vous ne pouvez pas envoyer des pièces jointes
  • Vous ne pouvez pas modifier vos messages
  •