[ create a new paste ] login | about

Link: http://codepad.org/LCuqm1J6    [ raw code | output | fork ]

PHP, pasted on Jan 24:
<?php

class PDOException extends Exception {}

class DataBaseException extends Exception {}

class PDO {
	function __construct($url, $user, $pw) {
	}
	function metodo($p) {
		echo "chamou metodo($p)";
	}
	function metodo_erro($p) {
		throw new PDOException('erro pdo');
	}
}

class MyPDO {
	private $pdo = null;
	function __construct($url, $user, $pw) {
		$this->pdo = new PDO($url, $user, $pw);
	}
	public function __call($name, $arguments) {
		try {
			call_user_func_array(array($this->pdo, $name), $arguments);
		} catch (PDOException $ex) {
			throw new DataBaseException('database error');
		}
	}
}

$db = new MyPDO('', '', '');
$db->metodo('p');
try {
    echo "\n";
    $db->metodo_erro('p');
} catch (Exception $e) {
	echo $e->getMessage();
}
  


Output:
1
2
chamou metodo(p)
database error


Create a new paste based on this one


Comments: