i am not new to PHP but definitely beginner in MVC stuff. I have read about MVC and get understanding that Model handles all DB operations ie. CRUD
I googled bit nd found Model.php
as
class Model {
private $connection;
public function __construct()
{
global $config;
$this->connection = mysql_connect($config['db_host'], $config['db_username'],
$config['db_password']) or die('MySQL Error: '. mysql_error());
mysql_select_db($config['db_name'], $this->connection);
}
public function execute($qry)
{
$exec = mysql_query($qry) or die('MySQL Error: '. mysql_error());
return $exec;
}
}
Now, i want to replace __construct()
with PDO and also change function execute($qry)
with PDO.
As of now i have included PDO.php
class with DB connection as require_once
in index.php
but in this way i feel that Model is not getting used at all.
I am using PIP
framework for PHP to use MVC.
Please let me know how can i use PDO here. Link to PIP framework is HERE