I am experienced with OOP but I am just starting to use the MVC model.
I would like to know what are the recommended practices to use PDO within the model and still keep a high level of abstraction. I have seen on the internet various approaches, the ones I liked the most were:
Making the model extends a specialized class for SQL queries, something like this:
class Car extends Model{...}
class Model extends SQLQuery{...}
Passing around a global database connection
class Car extends Model{
private $connection;
__constructor($pdo ...){
$this->connection = $pdo;
...
}
}
I also read some folks saying that all the queries should be made in the controller and use the model only to structure the data. I did not like much this one because it would not allow me to do such things like making a object change his self and update the database.
So, what are your recommendations? Thanks.