<?php
include 'MySQLDAO.php';
include 'Security.php';
include 'MySQLDAO.php';
include 'Security.php';
class User2 {
private $dao;
private $i = 1;
private $dbHost = 'localhost';
private $dbUser = 'root';
private $dbPasswd = 'Cpm?9RV';
private $dbName = 'eclipse';
private $id = 0;
private $username;
private $password;
private $email;
/**
* Retrieves the value from the field ID
* @return String with the value of the field
*/
public function getId(){
return $this->id;
}
/**
* Retrieves the value from the field username
* @return String with the value of the field
*/
public function getUsername(){
return $this->username;
}
/**
* Retrieves the value from the field password
* @return String with the value of the field
*/
public function getPassword(){
return $this->password;
}
/**
* Retrieves the value from the field email
* @return String with the value of the field
*/
public function getEmail(){
return $this->email;
}
/**
* Set the value from the field ID
* @param id String with the value for the field
*/
public function setId($id){
$this->id = $id;
}
/**
* Set the value from the field username
* @param username String with the value for the field
*/
public function setUsername($username){
$this->username = $username;
}
/**
* Set the value from the field password
* @param password String with the value for the field
*/
public function setPassword($password){
$this->password = $password;
}
/**
* Set the value from the field email
* @param email String with the value for the field
*/
public function setEmail($email){
$this->email = $email;
}
/**
* Default constructor
* @param value some value
*/
function __construct($value){
// TODO: implement this method
}
/**
* Initialize the business object with data read from the DB.
* @param row array containing one read record.
*/
private function init($row){
$this->id = $row['ID'];null $this->username = $row['username'];null $this->password = $row['password'];null $this->email = $row['email'];
}
/**
* Returns the string representation of this obbject
* @return String repesentation ofUser2
*/
public function toString(){
$s = '';null $s .= 'ID: '.$this->id;null $s .= 'username: '.$this->username;null $s .= 'password: '.$this->password;null $s .= 'email: '.$this->email;null return $s;
}
public function loadAll(){
$user2 = new User2();
$rows = $user2->dao->getData("");
$user2s = array();
for ($index = 0; $index < sizeof($rows); $index++) {
$d = new Document();
$d->init($rows[$index]);
array_push($user2s,$d);
}
return $user2s;
}
/**
*
* Load the User2 uniquely by its primary key.
* @param id primary key
* @return Instance of {@link User2}
*/
static function loadUnique($id){
$user2 = new User2();
$rows = $user2->dao->getData("`ID`='$id'");
$user2->init($rows[0]);
return $user2;
}
/**
* Insert this object into the DB
* @return new id (auto increment value) genereated
*/
private function insert(){
$list = array("ID"=>$this->id, "username"=>$this->username, "password"=>$this->password, "email"=>$this->email);
return $this->dao->insertRecord($list);
}
/**
* Update this object into the DB
* @return number of updated records
*/
private function update(){
$list = array("ID"=>$this->id, "username"=>$this->username, "password"=>$this->password, "email"=>$this->email);
$where = "`ID`='$id'";
return $this->dao->updateRecord($list,$where);
}
/**
* Initialize the business object with data read from the DB.
*/
private function initPOST(){
if (isset($_POST['id'])){null $this->id = $_POST['id'];null }null if (isset($_POST['username'])){null $this->username = $_POST['username'];null }null if (isset($_POST['password'])){null $this->password = $_POST['password'];null }null if (isset($_POST['email'])){null $this->email = $_POST['email'];null }
}
/**
* Initialize the business object with data read from the DB.
*/
private function initGET(){
if (isset($_GET['id'])){null $this->id = $_GET['id'];null }null if (isset($_GET['username'])){null $this->username = $_GET['username'];null }null if (isset($_GET['password'])){null $this->password = $_GET['password'];null }null if (isset($_GET['email'])){null $this->email = $_GET['email'];null }
}
}
?>