Witam!
Jestem dość nowy w pHp i mam taki problem. Kiedy parser przechodzi przez ten skrypt dostaję następujący komunikat:
Fatal error: Class 'MysqlException' not found in /dokumentacja/lib/db.php on line 142
Szukałem pomocy w manualach i na forum, ale niestety nic nie znalazłem. Będę bardzo wdzięczny za wszelką pomoc. Liczba 142 w kodzie oznacza oczywiście numer wiersza z komunikatu o błędzie.
<?php
//-----------Polaczenie z bazÄ…--------------
interface DB_Connection {
public function prepare($query);
public function execute($query);
}
interface DB_Statement {
public function execute();
public function bind_param($key, $value);
public function fetch_row();
public function fetch_assoc();
public function fetchall_assoc();
}
//--------Mysql--------------------------
class DB_Mysql implements DB_Connection {
protected $user;
protected $pass;
protected $dbhost;
protected $dbname;
protected $dbh;
public function __construct($user, $pass, $dbhost, $dbname) {
$this->user = $user;
$this->pass = $pass;
$this->dbhost = $dbhost;
$this->dbname = $dbname;
}
protected function connect() {
throw new MysqlException;
}
throw new MysqlException;
}
}
public function execute($query) {
if(!$this->dbh) {
$this->connect();
}
if(!$ret) {
throw new MysqlException;
}
return TRUE;
} else {
$stmt = new DB_MysqlStatement($this->dbh, $query);
$stmt->result = $ret;
return $stmt;
}
}
public function prepare($query) {
if(!$this->dbh) {
$this->connect();
}
return new DB_MysqlStatement($this->dbh, $query);
}
}
class DB_MysqlStatement implements DB_Statement {
public $result;
public $binds;
public $query;
public $dbh;
public function __construct($dbh, $query) {
$this->query = $query;
$this->dbh = $dbh;
throw new MysqlException("Nieprawidłowe połączenie do bazy danych");
}
}
public function bind_param($ph, $pv) {
$this->binds[$ph] = $pv;
return $this;
}
public function execute() {
foreach ($binds as $index => $name) {
$this->binds[$index + 1] = $name;
}
$query = $this->query;
if (isset($this->binds)){ foreach ($this->binds as $ph => $pv) {
}
}
if(!$this->result) {
throw new MysqlException;
}
return $this;
}
public function fetch_row() {
if(!$this->result) {
throw new MysqlException("Zapytanie nie zostało wykonane");
}
}
public function fetch_assoc() {
}
public function fetchall_assoc() {
while($row = $this->fetch_assoc()) {
$retval[] = $row;
}
return $retval;
}
}
class DB_Mysql_Test extends DB_Mysql {
protected $user = DB_USER;
protected $pass = DB_PASS;
protected $dbhost = DB_HOST;
protected $dbname = DB_BAZA;
public function __construct() { }
protected function connect()
{
throw new MysqlException;
}
throw new MysqlException;
}
if(!$ret) {
142 throw new MysqlException;
}
}
}
class DB_Mysql_Test_Debug extends DB_Mysql_Test {
protected $elapsedTime;
public function execute($query) {
// set timer;
parent::execute($query);
// end timer;
}
public function getElapsedTime() {
return $this->$elapsedTime;
}
}
class DB_Mysql_Prod extends DB_Mysql {
protected $user = "prod";
protected $pass = "secret";
protected $dbhost = "dbhost";
protected $dbname = "production";
public function __construct() { }
protected function connect()
{
throw new MysqlException;
}
throw new MysqlException;
}
if(!$ret) {
throw new MysqlException;
}
}
}
?>
Ten post edytował Virnel 2.04.2007, 14:46:35