Re: Tarieven Game/Web Designer/Developer
Zal een stukje uit me hoofd schrijven. Helaas kan dit forum niet normaal omgaan met inspringen dus die moet je er even bij bedenken.
<?php
/*
* MySQL
* Handles MySQL tasks
*
* @author Mark
* @version 1.0.0 - 13/03/2009
* @since PHP Version 5.0.4
*
*/
class MySQL {
public $error;
private $linkIdentifier;
private $server;
private $username;
private $password;
private $database;
/*
* Constructor; Defines MySQL settings.
*
* @param string $server
* @param string $username
* @param string $password
* @param string $database
* @return void
*/
public function MySQL($server, $username, $password, $database) {
$this->server = $server;
$this->username = $username;
$this->password = $password;
$this->database = $database;
}
/*
* Handles error messages.
*
* @param string $message
* @return void
*/
private function addErrorMessage($message) {
var $errorNumber = mysql_errno();
var $errorMessage = mysql_error();
$this->error[] = "MySQL ERROR: " . $errorMessage . " (" . $errorNumber . "):\n" . $message . "\n";
}
/*
* Open a connection to the MySQL server and select the database.
*
* @return boolean
*/
public function open() {
$this->linkIdentifier = @mysql_connect($this->server, $this->username, $this->password);
if (!$this->linkIdentifier) {
$this->addErrorMessage("Unable to connect to the MySQL server.");
return false;
}
if (!mysql_select_db($this->database, $this->linkIdentifier)) {
$this->addErrorMessage("Unable to select the database.");
return false;
}
return true;
}
/*
* Close MySQL connection.
*
* @return boolean
*/
public function close() {
if ($this->linkIdentifier) mysql_close($this->linkIdentifier);
$this->linkIdentifier = "";
}
}
?>
|