LaravelでSqliteを使いたいのですが
Illuminate \ Database \ QueryException (HY000)
SQLSTATE[HY000]: General error: 1 no such table: sessions (SQL: select * from "sessions" where "id" = vBIRaKWNW7XYPZeY1jXvpwWxB4sThfwtZD8hjLHE limit 1)
Previous exceptions
SQLSTATE[HY000]: General error: 1 no such table: sessions (HY000)
localhostに接続して作成したページを見ようとすると
このようなエラーがでてしまいます。
Sqliteで、database.sqliteにpeopleというテーブルを作っていて中身も作ってあります。
検索して調べて、試したのですが変わらずエラーがでてしまいました。
よろしくお願いします。
ソース
env
1DB_CONNECTION=sqlite 2DB_DATABASE=database.sqliteの絶対パス
database.php
'default' => env('DB_CONNECTION', 'sqlite'), 'connections' => [ 'sqlite' => [ 'driver' => 'sqlite', 'url' => env('DATABASE_URL'), 'database' => env('DB_DATABASE', database_path('database.sqlite')), 'prefix' => '', ],
HelloController
1<?php 2 3namespace App\Http\Controllers; 4 5use Illuminate\Http\Request; 6use Illuminate\Http\Response; 7use Illuminate\Support\Facades\Input; 8 9use App\Http\Requests\HelloRequest; 10 11use Illuminate\Support\Facades\DB; 12 13use Validator; 14 15use Illuminate\Support\Facades\Session; 16use Illuminate\Support\Facades\Auth; 17 18use App\Person; 19 20class HelloController extends Controller 21{ 22 23 public function index(Request $request) 24 { 25 $items = DB::table('people')->get(); 26 return view('hello.index', ['items' => $items]); 27 } 28 29 public function post(Request $request){ 30 $item = DB::select('select * from people'); 31 return view('hello.index', ['items'=> $item]); 32 } 33 34 public function add(Request $request){ 35 return view('hello.add'); 36 } 37 38 public function create(Request $request){ 39 40 41 $param = [ 42 'name' => $request->name, 43 'mail' => $request->mail, 44 'age' => $request->age, 45 ]; 46 DB::insert('insert into people (name, mail, age) values (:name, :mail, :age)', $param); 47 return redirect('/hello'); 48 } 49 50 public function edit(Request $request){ 51 $param = ['id' => $request->id]; 52 $item = DB::select('select * from people where id = :id', 53 $param); 54 return view('hello.edit', ['form' => $item[0]]); 55 } 56 57 public function updata(Request $request){ 58 $param = [ 59 'id' => $request->id, 60 'name' => $request->name, 61 'mail' => $request->mail, 62 'age' => $request->age, 63 ]; 64 DB::updata('updata people set name =:name, mail = :mail, 65 age =:age where id = :id, $param'); 66 return redirect('/hello'); 67 } 68 69 public function show(Request $request){ 70 $id = $request->id; 71 $item = DB::table('people')->where('id', $id)->first(); 72 return view('hello.show', ['item' => $item]); 73 } 74 75}
web.php
<?php use App\Http\middleware\HeloMiddleware; Route::get('/', function () { return view('welcome'); }); Route::get('hello', 'HelloController@index'); Route::post('hello', 'HelloController@post'); Route::get('hello/add', 'HelloController@add'); Route::post('hello/add', 'HelloController@create'); Route::get('hello/edit', 'HelloController@edit'); Route::post('hello/edit', 'HelloController@updata'); Route::get('hello/show', 'HelloController@show');
回答1件
あなたの回答
tips
プレビュー