php - Connect DB automatically in Codeigniter? -


in project uploading video through 1 file. in using db connections like

mysql_connect("localhost", "root", '') or die(mysql_error()); mysql_select_db("lmsci3") or die(mysql_error()); 

here connecting manually giving db name, username , password. want connect automatically. how that?

in database.php

write following code, everytime don't need make connection, have write code once , can use models , functions.

$db['default'] = array(     'dsn'   => '',     'hostname' => 'localhost',     'username' => 'username',     'password' => 'password',     'database' => 'databasename',     'dbdriver' => 'mysqli',     'dbprefix' => '',     'pconnect' => false,     'db_debug' => (environment !== 'production'),     'cache_on' => false,     'cachedir' => '',     'char_set' => 'utf8',     'dbcollat' => 'utf8_general_ci',     'swap_pre' => '',     'encrypt' => false,     'compress' => false,     'stricton' => false,     'failover' => array(),     'save_queries' => true ); 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -