I started some days ago with FlightPHP. Now I created my own model called imagePreviewModel.
Here is the model:
<?php
class imagePreviewModel{
private $db;
public function __construct(PDO $db){
$this->db = $db;
}
public function getAllImages(){
return $this->db->query('SELECT * FROM images');
}
}
?>
Inside of the controller I registered the class and called the method getAllImages(). Now I open the page with the Browser and get an error: Call to undefined method PDO::getAllImages() (0)
Here is the code of the controller:
<?php
require 'flight/Flight.php';
include 'private/models/imagePreviewModel.php';
Flight::route('/', function(){
Flight::register('imagePreviewModel', 'PDO', array('mysql:host=localhost;dnbname=share','root',''));
$imagePreviewModel = Flight::imagePreviewModel();
$List = $imagePreviewModel->getAllImages();
Flight::render('general', NULL);
});
Flight::start();
?>
Can anyone help me?
I think I found the problem. I register the class PDO, but I want to register a class called 'imagePreviewModel'. How can I register that class?
At the FlightPHP page is this example:
// Register your class
Flight::register('user', 'User');
// Get an instance of your class
$user = Flight::user();
But what is the class name and the parameter? And why the wrote two times User? I need a little explanation.