laravel database connection returns undefined index error

前端 未结 6 975
野趣味
野趣味 2021-01-22 16:53

I am developing a project using laravel 4 framework. In my database.php file I get the following error:

  Undefined index: driver 

And my conne

6条回答
  •  执念已碎
    2021-01-22 17:29

    Moving the 'driver' key up a level should fix the issue.

    $connections = array(
        'mysql' => array(
            'read' => array(
                'host'      => 'localhost',
                'database'  => 'app_system',
                'username'  => 'root',
                'password'  => 'root',
                'charset'   => 'utf8',
                'collation' => 'utf8_unicode_ci',
                'prefix'    => '',
            ),
            'write' => array(
                'host'      => 'localhost',
                'database'  => 'app_system',
                'username'  => 'root',
                'password'  => 'root',
                'charset'   => 'utf8',
                'collation' => 'utf8_unicode_ci',
                'prefix'    => '',
            ),
            'driver' => 'mysql'
        ),
    

    Most of the other params that are shared can me moved as well

    $connections = array(
        'mysql' => array(
            'read' => array(
                'host'      => 'localhost',
            ),
            'write' => array(
                'host'      => 'localhost',
            ),
            'driver'    => 'mysql',
            'database'  => 'app_system',
            'username'  => 'root',
            'password'  => 'root',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
        ),
    

提交回复
热议问题