I'm new to the Slim Framework and I'm trying to build a simple webapp connected with PDO to a MySQL database (and with a Twig/Bootstrap UI).
I try to access database from a controller named "PagesController" :
class PagesController extends Controller {
    public function getLieu(RequestInterface $request, ResponseInterface $response) {
        // this two lines crash :
        $lieux = $this->$database->query('SELECT * FROM Lieu');
        var_dump($lieux);
        $this->render($response, 'pages/lieu.twig');
    }
}
But I'm only able to call my PDO object from index.php or the from the parent abstrat class named "Controller" :
class Controller {
    private $container;
    public function __construct($container) {
        $this->container = $container;
        // those 3 lines works well :
        $database = $this->container->get('db');
        $lieux = $database->query('SELECT * FROM Lieu');
        var_dump($lieux);
    }
    public function render(ResponseInterface $response, $file) {
        $this->container->view->render($response, $file);
    }
}
Is somebody here can help me ?
Thank you !
 
    