Laravel Eloquent入门
Laravel Eloquent 命令行工具
进入命令行工具
php artisan tinker
$name='kafu'
$name
写入MySQL数据(1)
$users = new App\User;
$users->name='kafu'
$users->email='[email protected]'
$users->save()
$users->toArray();
写入数据(2)
$users->create(['name'=>'zhangsan','email'=>'[email protected]']);
protected $fillable=['name','email'];
更新数据(1)
$first = App\Users::find(1);
$first->name='lisi';
$first->save();
更新数据(2)
$first = App\Users::find(1);
$first->update(['name'=>'zhangsan']);
获取数据
$result = App\Users::where('name','=','kafu')->get();
$result = App\Users::where('name','=','kafu')->first();
$result = App\Users::where('name','=','kafu')->find(1);