Search code examples
phpfat-free-framework

Retrieving data from database in a fat free framework


I start learning fat-free framework v 3.7, I just read the documentation, I am trying to read the database and showing the result into HTML, but it doesn't work,

this is index.php

<?php
$f3 = require('vendor/bcosca/fatfree-core/base.php');
$db=new DB\SQL(
'mysql:host=localhost;port=3306;dbname=db',
'username',
'');
$f3->set('result',$db->exec('SELECT * FROM dokumen'));
echo Template::instance()->render('abc.htm');

this is the html

<repeat group="{{ @result }}" value="{{ @item }}">
<span>{{ @item.title  }}</span>
</repeat>

that code give error like this:

Internal Server Error
mkdir(): Permission denied

and if I change Template to view like this

before

echo Template::instance()->render('abc.htm');

after

$view = new View;
 echo $view->render('abc.htm');

just give me output

{{ @item.title }}

Solution

  • This problem solved!

    the main problem of this error, files does not have permission to make tmp folder, btw I use ubuntu 18.04, to solve this problem just change the permission in folder location of the project. and type like this

    chmod -v 777 DIR_NAME