<?php
class Database extends PDO {
function __construct($dsn, $username="", $password="", $driver_options=array()) {
parent::__construct($dsn,$username,$password, $driver_options);
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('ChainablePDOStatement', array($this)));
}
}
class ChainablePDOStatement extends PDOStatement {
protected $pdo;
protected function __construct($pdo) {
$this->pdo = $pdo;
}
public function bindValue($parameter, $value, $data_type = PDO::PARAM_STR) {
parent::bindValue($parameter, $value, $data_type);
return $this;
}
public function bindParam($paramno, &$param, $type = NULL, $maxlen = NULL, $driverdata = NULL) {
parent::bindParam($paramno, $param, $type, $maxlen, $driverdata);
return $this;
}
public function execute($bound_input_params = NULL) {
parent::execute($bound_input_params);
return $this;
}
}