laravel控制器在插入后不返回值

时间:2015-10-16 12:59:38

标签: laravel-4 controller return-value

当我评论插入查询时,返回工作。但查询返回不起作用。如果有人可以立即帮助,那将是很好的

 public function regCustomer()
{
    $arr = [];

    $cus_name = Input::get('cusname');
    $cus_address = Input::get( 'address' );
    $cus_phone = Input::get( 'phone' );
    $cus_email = Input::get( 'email' );

    try{
        DB::table('Customers')->insert(
            array(
                'customer_name' => $cus_name,
                'address' => $cus_address,
                'phone' => $cus_phone,
                'email' => $cus_email
                )
        );

       return 1;

    }catch(Exception $ex){
        return '0';
    }
}

1 个答案:

答案 0 :(得分:0)

替换catch块参数以匹配:

catch (\Illuminate\Database\QueryException $e)