|
|
|
#1 (permalink) |
|
Neuer Benutzer
Registriert seit: 08.06.2007
Beiträge: 11
|
Hallo, hab eine Klasse geschrieben zur Verbindung mit meiner DB:
Code:
class dbConnector {
private $connection = NULL;
private $result = NULL;
private static $uniqueInstance = NULL;
protected function __construct() {}
private final function __clone() {}
public static function singleton() {
if (self::$uniqueInstance === NULL) {
self::$uniqueInstance = new dbConnector;
}
return self::$uniqueInstance;
}
public function connect($host, $database, $user, $pass) {
$this->connection = mysql_connect($host,$user,$pass,TRUE);
mysql_select_db($database, $this->connection);
}
public function disconnect() {
if (is_resource($this->connection)) {
mysql_close($this->connection);
}
}
public function query($query) {
if (is_resource($this->connection)) {
$result = mysql_query( $query, $this->connection );
if ($result != null and is_resource($result))
return $result;
}
}
}
Code:
class USER{
private $connection;
function __construct(){
require_once ('dbConnector.class.php');
$this->connection = dbConnector::singleton();
$this->connection->connect('localhost','usr_1', 'usr_db', 'test');
}
function addUser($Anrede, $Name, $Vorname, $extKey, $Strasse, $Hausnummer, $Zusatz, $PLZ, $Ort, $E_mail, $Einstellungsdatum, $Password){
$this->connection->query("INSERT INTO PROFIL (Anrede,Name,Vorname,Ext_Schluessel,Strase,Hausnummer,Zusatz,PLZ,Ort,E_mail,Einstellungsdatum) VALUES ('$Anrede', '$Name', '$Vorname', '$extKey', '$Strasse', '$Hausnummer', '$Zusatz', '$PLZ', '$Ort', '$E_mail', '$Einstellungsdatum');");
$user_ID = getUIDFromMail($E_mail);
$result = $this->connection->query("INSERT INTO LOGIN (User_ID, Passwort) VALUES ('$user_ID','$Password');");
}//End addUser
function getUIDFromMail($E_mail){
$result = $this->connection->query("SELECT User_ID FROM PROFIL WHERE E_Mail == $E_mail");
}
function setUserAnrede($Anrede){
$result = $this->connection->query("SELECT * FROM PROFIL");
}//End setUserAnrede
}
Code:
require_once ('user.php');
$user = new USER();
$user->addUser("Herr", "Mustermann", "Martin", "0815", "Hauptstr.", "24", "b", "22117", "Musterstadt", "email@adresse.de", "2007.01.01", "pwd");
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in der Zeile mit private $connection; kann mir jemand das jmd. erklären und helfen?! |
|
|
|
![]() |
| Lesezeichen |
| Themen-Optionen | |
|
|
Ähnliche Themen
|
||||
| Thema | Autor | Forum | Antworten | Letzter Beitrag |
| Eigene Klasse + mootoolsJson | .sophor | JavaScript | 6 | 15.06.2007 13:01 |
| mysql sum | onkeltobi | Serverseitige Skriptsprachen | 1 | 08.04.2007 13:12 |
| Mysql Abfrage | onkeltobi | Serverseitige Skriptsprachen | 1 | 16.03.2007 18:28 |
| Suche Rahmen-Klasse in Framework etc. | b.asile | Sonstige Probleme | 2 | 07.02.2007 19:07 |
| XSL-T --->(Klasse?) für JSP / PHP / Frameworks | _level0 | Sonstige Probleme | 1 | 20.03.2006 21:07 |