Laravel 4 cannot run whole RAW queries

前端 未结 3 2172
再見小時候
再見小時候 2021-02-14 17:58

I would like to use the DB class of laravel to execute a mysql query but none of the functions provided by Laravel are working.

None of those is working: DB::statment()

3条回答
  •  迷失自我
    2021-02-14 18:21

    What about this code? I find it pretty usefull to use migrations & db seeding - especialy for deployment.

    Schema::create('users', function($table){
        $table->increments('id');
        $table->string('u_username');
        $table->string('u_email');
        $table->string('password');
        $table->datetime('u_regdate');
        $table->date('u_birthday');
        $table->integer('u_lastlogin');
        $table->integer('u_logcout')->default(0);
        $table->tinyinteger('u_level')->default(0);
        $table->tinyinteger('u_language')->default(0);
        $table->tinyinteger('u_status')->default(0);
        $table->tinyinteger('u_gender')->default(0);
    });
    
    
    // Repeat this for other users as well
    User::create([
        'u_username' =>     'admin',
        'u_email' =>        'admin@example.com',
        'password' =>       Hash::make('users-password'),
        'u_regdate' =>      date('Y-m-d H:i:s'),
        'u_birthday' =>     '1980-01-01',
        'u_lastlogin' =>    0,
        'u_logcout' =>      0,
        'u_level' =>        9,
        'u_language' =>     0,
        'u_status' =>       0,
        'u_gender' =>       0,
    ]);
    

提交回复
热议问题