laravel 4.2中的PDO异常

时间:2014-08-04 18:16:50

标签: mysql laravel pdo

我在wamp上安装了laravel4.2,我使用Eloquent将数据插入数据库。 打开浏览器并输入url:localhost:8000 / register时出错 PDO例外(2002年) SQLSTATE [HY000] [2002]无法建立连接,因为目标计算机主动拒绝它

RegisterController.php

public function store()
{
    $validation = new RegisterValidator ;
    if($validation -> passes())
    {
        $register = new Register ;
        $register->name     = Input::get('name') ;
        $register->lname    = Input::get('lname') ;
        $register->gender   = Input::get('gender') ;
        $register->year     = Input::get('year') ;
        $register->month    = Input::get('month') ;
        $register->day      = Input::get('day') ;
        $register->username = Input::get('username') ;
        $register->password = Input::get('password') ;
        $register->mail     = Input::get('mail') ;
        $register->save() ;
        return Redirect::route('socialnetwork.register');
    }
    return Redirect::back()->withInput()->withErrors($validation->errors);

}

Register.php

<?php namespace App\Models ;

use Eloquent;

class Register extends \Eloquent{

    protected $table = 'register' ;
}
?>

应用\设置\ database.php中

    'mysql' => array(
        'driver'    => 'mysql',
        'host'      => '127.0.0.1',
        'database'  => 'db_socialnetwork',
        'username'  => 'root',
        'password'  => '',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
    ),

请告诉我我该怎么办? 感谢

0 个答案:

没有答案