php - Setting SQLite as my database in laravel 5 -
i'm creating small mockup social network in laravel 5. want use sqlite database keep things small , local. i'm having trouble, however, getting work.
here's code (using blade) use table display row in database:
@extends('layouts.master') @section('title') testing2 @stop @section('content') second test <a href="/">back page 1</a> <table> <tr><th>author</th> <th>text</th></tr> @foreach($posts $post) <tr> <td> {{$posts->author}} </td> </tr> <tr> <td> {{$posts->text}} </td> </tr> @endforeach </table> @stop
"author" , "text" being 2 columns in database. here route use generate page:
route::get('test2', function () { $sql = "select * posts"; $posts = db::select($sql); return view::make('test2')->withposts($posts); });
i know database there, i've placed in /database directory of app:
lastly, modified config\database.php file set sqlite default database:
when try , view blade page using route function, following error: "sqlstate[hy000] [2002] no connection made because target machine actively refused it."
i'm doing wrong somewhere connecting database, don't know what. have set properly?
place database in storage folder , mention path in database. should have php driver installed.
do in app/config/database.php:
<?php return array( 'default' => 'sqlite', 'connections' => array( 'sqlite' => array( 'driver' => 'sqlite', 'database' => __dir__.'/../database/production.sqlite', 'prefix' => '', ), ), ); ?>
Comments
Post a Comment