real = $real; } public function bind_param($typinf, &$v1, &$v2 = null, &$v3 = null, &$v4 = null, &$v5 = null, &$v6 = null, &$v7 = null, &$v8 = null, &$v9 = null, &$v10 = null) { echo "bind: "; for($i = 0; $i < func_num_args(); $i++) echo ' ' . func_get_arg($i); echo "\r\n"; // this should work as I read the docs, but ot does not so work around below // call_user_func_array(array($this->real, 'bind_param'), func_get_args()); $refarr = array_slice(array($typinf, &$v1, &$v2, &$v3, &$v4, &$v5, &$v6, &$v7, &$v8, &$v9, &$v10), 0, func_num_args()); call_user_func_array(array($this->real, 'bind_param'), $refarr); } public function execute() { $this->real->execute(); } public function store_result() { $this->real->store_result(); } public function bind_result(&$v1, &$v2 = null, &$v3 = null, &$v4 = null, &$v5 = null, &$v6 = null, &$v7 = null, &$v8 = null, &$v9 = null, &$v10 = null) { // this should work as I read the docs, but ot does not so work around below // call_user_func_array(array($this->real, 'bind_result'), func_get_args()); $refarr = array_slice(array(&$v1, &$v2, &$v3, &$v4, &$v5, &$v6, &$v7, &$v8, &$v9, &$v10), 0, func_num_args()); call_user_func_array(array($this->real, 'bind_result'), $refarr); } public function fetch() { $res = $this->real->fetch(); echo "fetch: " . ($res ? "true" : "false") . "\r\n"; return $res; } public function close() { $this->real->close(); } } class log_mysqli { private $real; public function __construct($host, $un, $pw, $db) { $this->real = new mysqli($host, $un, $pw, $db); } public function prepare($sql) { echo "prepare: $sql\r\n"; return new log_mysqli_stmt($this->real->prepare($sql)); } public function close() { $this->real->close(); } } // some database code $con = new log_mysqli('localhost', 'root', '', 'Test'); if(mysqli_connect_errno()) die(mysqli_connect_error()); if($stmt = $con->prepare('SELECT f1,f2 FROM t1 WHERE f1 > ?')) { $stmt->bind_param('i', $cutoff); $cutoff = 5; $stmt->execute(); $stmt->store_result(); $f1 = 0; $f2 = ''; $stmt->bind_result($f1, $f2); while ($stmt->fetch()) { print $f1 . ' ' . $f2 . "\n"; } $stmt->close(); } else { die($con->error); } $con->close(); ?>