I just don't know why i am getting this err. Expert please help me out. I googled and seen very similar type of problem in SO also but I couldn't figure out what actually wrong in my code -- I became helpless here.
My code snippest is given below :
Database:
class Database extends PDO
{
function __construct($dbtype,$dbhost,$dbname,$dbuser,$dbpass)
{
parent::__construct($dbtype.':host='.$dbhost.";dbname=".$dbname,$dbuser,$dbpass);
}
}
Model :
<?php
/**
* Base Model Class
*/
class Model
{
function __construct()
{
$this->db = new Database(DB_TYPE,DB_HOST,DB_NAME,DB_USER,DB_PASS);
}
}
Controller:
<?php
/**
* Auth Controller
*/
class RegistrationController extends Controller
{
function __construct()
{
parent::__construct();
}
public function index()
{
$this->view->render('registration');
}
public function registration()
{
$data = array();
$data['username'] = $_POST['username'];
$data['email'] = $_POST['email'];
$data['contact'] = $_POST['contact'];
$data['password'] = Hash::create('md5', $_POST['password'], HASH_PASSWORD_KEY);
$this->model->registration($data);
}
}
Registration Model :
class Registration extends Model
{
function __construct()
{
parent::__construct();
}
public function registration($data)
{
$sql = $this->db->prepare("INSERT INTO users (username, email, contact ,password) VALUES (:username, :email, :contact, :password)");
$sql->execute(array(
':username' => $data['username'],
':email' => $data['email'],
':contact' => $data['contact'],
':password' => $data['password']
));
}
}