<?php class Model { protected $db = null; public function __construct($host = null, $db = null, $user = null, $pass = null) { $this->db = new PDO('mysql:host='.$host.';database='.$db.';charset=utf8', $user, $pass); } protected function preexe($query = null, $patterns = array(), $returned = null) { try { $stmt = null; $stmt = $this->db->prepare($query); foreach($patterns as $key => $value) { $stmt->BindValue($key, $value); } $stmt->execute(); if(is_null($returned)) { return true; } else { return $stmt->returned; } } catch( ) { return false; } } protected function lastid() { return $this->db->lastinsertid(); } } ?>