Adding changes from production server. Pls, stop making changes live. Hrmpf.
This commit is contained in:
1 parent
243008cff5
commit
ca1fcc8173
104 files changed
+9231
-4853
No files matched your search
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Collection object for handling multiple rows and creating objects from database results
|
||||
*
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
abstract class mapper_Collection implements Iterator {
|
||||
protected $mapper;
|
||||
protected $total = 0;
|
||||
protected $raw = array();
|
||||
|
||||
private $result;
|
||||
private $pointer;
|
||||
private $objects = array();
|
||||
|
||||
function __construct(array $raw = null, mapper_Mapper $mapper = null) {
|
||||
if (!is_null($raw) && !is_null($mapper)) {
|
||||
$this->rewind();
|
||||
$this->raw = $raw;
|
||||
$this->total = count($raw);
|
||||
}
|
||||
$this->mapper = $mapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an object to the collection
|
||||
**/
|
||||
function add(domain_DomainObject $object) {
|
||||
$class = $this->targetClass();
|
||||
if (!($object instanceof $class)) {
|
||||
throw new Exception("This is a {$class} collection");
|
||||
}
|
||||
$this->notifyAccess();
|
||||
$this->objects[$this->total] = $object;
|
||||
$this->total++;
|
||||
}
|
||||
|
||||
abstract function targetClass();
|
||||
|
||||
protected function notifyAccess() {
|
||||
// something is coming here..
|
||||
}
|
||||
|
||||
private function getRow($num) {
|
||||
$this->notifyAccess();
|
||||
if ($num >= $this->total || $num < 0) {
|
||||
return null;
|
||||
}
|
||||
if (isset($this->objects[$num])) {
|
||||
return $this->objects[$num];
|
||||
}
|
||||
if (isset($this->raw[$num])) {
|
||||
// object has not been created yet
|
||||
$this->objects[$num]=$this->mapper->createObject($this->raw[$num]);
|
||||
return $this->objects[$num];
|
||||
}
|
||||
}
|
||||
|
||||
public function rewind() {
|
||||
$this->pointer = 0;
|
||||
}
|
||||
|
||||
public function current() {
|
||||
return $this->getRow($this->pointer);
|
||||
}
|
||||
|
||||
public function key() {
|
||||
return $this->pointer;
|
||||
}
|
||||
|
||||
public function next() {
|
||||
$row = $this->getRow($this->pointer);
|
||||
if ($row) {
|
||||
$this->pointer++;
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function valid() {
|
||||
return (!is_null($this->current()));
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Abstract mapper class for database mapping from domain
|
||||
*
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
abstract class mapper_Mapper {
|
||||
protected static $PDO;
|
||||
|
||||
function __construct() {
|
||||
if (!isset(self::$PDO)) {
|
||||
$dsn = getDSN("PDO");
|
||||
if (is_null($dsn)) {
|
||||
throw new Exception("No DSN");
|
||||
}
|
||||
try {
|
||||
self::$PDO = new PDO($dsn["dsn"], $dsn["username"], $dsn["password"]);
|
||||
self::$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch (Exception $e) {
|
||||
throw new Exception("Database connection error: ". getDSN());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function find($id) {
|
||||
// check if object allready has been fetch from database
|
||||
$old = $this->getFromMap($id);
|
||||
if ($old) {
|
||||
return $old;
|
||||
}
|
||||
|
||||
// get object from database
|
||||
$this->selectStmt()->execute(array($id));
|
||||
$array = $this->selectStmt()->fetch();
|
||||
$this->selectStmt()->closeCursor();
|
||||
if (!is_array($array)) {
|
||||
return null;
|
||||
}
|
||||
if (!isset($array['id'])) {
|
||||
return null;
|
||||
}
|
||||
$object = $this->createObject($array);
|
||||
return $object;
|
||||
}
|
||||
|
||||
function findAll() {
|
||||
$this->selectAllStmt()->execute(array());
|
||||
return $this->getCollection( $this->selectAllStmt()->fetchAll( PDO::FETCH_ASSOC ) );
|
||||
}
|
||||
|
||||
function createObject($array) {
|
||||
$old = $this->getFromMap($array['id']);
|
||||
if ($old) { return $old; }
|
||||
|
||||
// construct object
|
||||
$obj = $this->doCreateObject($array);
|
||||
|
||||
// add object to object watcher map
|
||||
$this->addToMap($obj);
|
||||
$obj->markClean();
|
||||
return $obj;
|
||||
}
|
||||
|
||||
function insert(domain_DomainObject $obj) {
|
||||
$this->doInsert($obj);
|
||||
$this->addToMap($obj);
|
||||
}
|
||||
|
||||
function delete(domain_DomainObject $obj) {
|
||||
$this->doDelete($obj);
|
||||
//$this->removeFromMap($obj);
|
||||
}
|
||||
|
||||
private function getFromMap($id) {
|
||||
return domain_ObjectWatcher::exists($this->targetClass(), $id);
|
||||
}
|
||||
|
||||
private function addToMap(domain_DomainObject $obj) {
|
||||
return domain_ObjectWatcher::add($obj);
|
||||
}
|
||||
|
||||
abstract function update(domain_DomainObject $object);
|
||||
protected abstract function doCreateObject(array $array);
|
||||
protected abstract function doInsert(domain_DomainObject $object);
|
||||
protected abstract function doDelete(domain_DomainObject $object);
|
||||
protected abstract function targetClass();
|
||||
protected abstract function selectStmt();
|
||||
protected abstract function selectAllStmt();
|
||||
protected abstract function deleteStmt();
|
||||
abstract function getCollection(array $raw);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* MembershipCard collection - collection of elements in the user database
|
||||
*
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class mapper_MembershipCardCollection extends mapper_Collection {
|
||||
function targetClass() {
|
||||
return "domain_MembershipCard";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* MembershipCard object mapper to database
|
||||
*
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
//require_once( "mapper/Mapper.php" );
|
||||
//require_once( "mapper/UserMapper.php" );
|
||||
//require_once( "mapper/Collections.php" );
|
||||
|
||||
class mapper_MembershipCardMapper extends mapper_Mapper {
|
||||
|
||||
function __construct() {
|
||||
// initialize database connection and common setup
|
||||
parent::__construct();
|
||||
|
||||
// prepare SQL statements
|
||||
$this->selectStmt = self::$PDO->prepare(
|
||||
"SELECT c.id as id, u.id as userId, u.hasCard, u.lastSticker, c.date as created FROM din_usedcardno c LEFT JOIN din_user u ON c.id = u.cardno WHERE c.id=?");
|
||||
$this->selectAllStmt = self::$PDO->prepare(
|
||||
"SELECT u.id as userId, u.cardno as id, u.hasCard, u.lastSticker, c.date as created FROM din_user u LEFT JOIN din_usedcardno c ON u.cardno = c.id");
|
||||
$this->findByUserIdStmt = self::$PDO->prepare(
|
||||
"SELECT c.id as id, u.id as userId, u.hasCard, u.lastSticker, c.date as created FROM din_usedcardno c LEFT JOIN din_user u ON c.id = u.cardno WHERE u.id=?");
|
||||
// $this->updateStmt = self::$PDO->prepare(
|
||||
// "UPDATE din_user SET
|
||||
// cardno=?,
|
||||
// expires=?,
|
||||
// WHERE id=?");
|
||||
// $this->insertStmt = self::$PDO->prepare(
|
||||
// "INSERT INTO din_user (
|
||||
// expires
|
||||
// ) values (?)");
|
||||
// $this->deleteStmt = self::$PDO->prepare(
|
||||
// "DELETE FROM din_user WHERE id=?");
|
||||
}
|
||||
|
||||
protected function doCreateObject(array $array) {
|
||||
$obj = new domain_MembershipCard($array["id"]);
|
||||
|
||||
$user_mapper = new mapper_UserMapper();
|
||||
$obj->setUser($user_mapper->find($array["userId"]));
|
||||
|
||||
$obj->setCreated(new DateTime($array["created"]));
|
||||
if ($array["hasCard"]) $obj->setProduced(new DateTime()); // set produced date to now if card has been produced
|
||||
$obj->setLastSticker($array["lastSticker"]);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
protected function doInsert(domain_DomainObject $object) {
|
||||
}
|
||||
|
||||
function update(domain_DomainObject $object) {
|
||||
}
|
||||
|
||||
protected function doDelete(domain_DomainObject $object) {
|
||||
}
|
||||
|
||||
function selectStmt() {
|
||||
return $this->selectStmt;
|
||||
}
|
||||
|
||||
function selectAllStmt() {
|
||||
return $this->selectAllStmt;
|
||||
}
|
||||
|
||||
function deleteStmt() {
|
||||
//return $this->deleteStmt;
|
||||
}
|
||||
|
||||
function findByUserId($userid) {
|
||||
$this->findByUserIdStmt->execute(array($userid));
|
||||
return new mapper_MembershipCardCollection($this->findByUserIdStmt->fetchAll(), $this);
|
||||
}
|
||||
|
||||
function getCollection(array $raw) {
|
||||
return new mapper_MembershipCardCollection($raw, $this);
|
||||
}
|
||||
|
||||
protected function targetClass() {
|
||||
return "domain_MembershipCard";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Membership collection - collection of elements in the user database
|
||||
*
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class mapper_MembershipCollection extends mapper_Collection {
|
||||
function targetClass() {
|
||||
return "domain_Membership";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Membership object mapper to database
|
||||
*
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class mapper_MembershipMapper extends mapper_Mapper {
|
||||
|
||||
function __construct() {
|
||||
// initialize database connection and common setup
|
||||
parent::__construct();
|
||||
|
||||
// prepare SQL statements
|
||||
$this->selectStmt = self::$PDO->prepare(
|
||||
"SELECT u.id as userId, u.cardno, u.expires FROM din_user u WHERE u.id=?");
|
||||
$this->selectAllStmt = self::$PDO->prepare(
|
||||
"SELECT u.id as userId, u.cardno, u.expires FROM din_user u");
|
||||
$this->updateStmt = self::$PDO->prepare(
|
||||
"UPDATE din_user SET
|
||||
cardno=?,
|
||||
expires=?,
|
||||
WHERE id=?");
|
||||
// $this->insertStmt = self::$PDO->prepare(
|
||||
// "UPDATE din_user (
|
||||
// cardno, username, password, firstname, lastname, addresstype, valid_address, email, birthdate, placeOfStudy, passwordReset, division_id_request
|
||||
// ) values (?)");
|
||||
$this->deleteStmt = self::$PDO->prepare(
|
||||
"DELETE FROM din_user WHERE id=?");
|
||||
$this->findByUserIdStmt = self::$PDO->prepare(
|
||||
"SELECT u.id as userId, u.cardno, u.expires FROM din_user u WHERE u.id=?");
|
||||
}
|
||||
|
||||
protected function doCreateObject(array $array) {
|
||||
$obj = new domain_Membership($array["userId"]);
|
||||
|
||||
$user_mapper = new mapper_UserMapper();
|
||||
$obj->setUser($user_mapper->find($array["userId"]));
|
||||
|
||||
$card_mapper = new mapper_MembershipCardMapper();
|
||||
$obj->setCard($card_mapper->find($array["cardno"]));
|
||||
|
||||
$obj->setCreated(new DateTime("-9999-12-31"));
|
||||
$obj->setStarts(new DateTime("-9999-12-31"));
|
||||
$obj->setExpires(new DateTime($array["expires"]));
|
||||
return $obj;
|
||||
}
|
||||
|
||||
protected function doInsert(domain_DomainObject $object) {
|
||||
// $values = array($object->getUsername());
|
||||
// //$this->insertStmt->execute($values);
|
||||
// $id = self::$PDO->lastInsertId();
|
||||
// $object->setId($id);
|
||||
}
|
||||
|
||||
function update(domain_DomainObject $object) {
|
||||
$values = array(
|
||||
$object->getCard()->getId(),
|
||||
$object->getExpires(),
|
||||
$object->getId()
|
||||
);
|
||||
print_r($values);
|
||||
//$this->updateStmt->execute($values);
|
||||
}
|
||||
|
||||
protected function doDelete(domain_DomainObject $object) {
|
||||
$values = array($object->getId());
|
||||
$this->deleteStmt->execute($values);
|
||||
}
|
||||
|
||||
function selectStmt() {
|
||||
return $this->selectStmt;
|
||||
}
|
||||
|
||||
function selectAllStmt() {
|
||||
return $this->selectAllStmt;
|
||||
}
|
||||
|
||||
function deleteStmt() {
|
||||
//return $this->deleteStmt;
|
||||
}
|
||||
|
||||
function findByUserId($userid) {
|
||||
$this->findByUserIdStmt->execute(array($userid));
|
||||
return new mapper_MembershipCollection($this->findByUserIdStmt->fetchAll(), $this);
|
||||
}
|
||||
|
||||
function findByCardId($userid) {
|
||||
//$this->findByCardIdStmt->execute(array($userid));
|
||||
//return new mapper_UserUpdateCollection($this->findByUserIdStmt->fetchAll(), $this);
|
||||
$this->selectStmt->execute(array($userid));
|
||||
return new mapper_MembershipCollection($this->selectStmt->fetchAll(), $this);
|
||||
}
|
||||
|
||||
function getCollection(array $raw) {
|
||||
return new mapper_MembershipCollection($raw, $this);
|
||||
}
|
||||
|
||||
protected function targetClass() {
|
||||
return "domain_Membership";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* User address collection - collection of elements in the user address database
|
||||
*
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class mapper_UserAddressCollection extends mapper_Collection {
|
||||
function targetClass() {
|
||||
return "domain_UserAddress";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* User address object mapper to database
|
||||
*
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class mapper_UserAddressMapper extends mapper_Mapper {
|
||||
|
||||
function __construct() {
|
||||
// initialize database connection and common setup
|
||||
parent::__construct();
|
||||
|
||||
// prepare SQL statements
|
||||
$this->selectStmt = self::$PDO->prepare(
|
||||
"SELECT user_id, street, zipcode FROM din_useraddressno WHERE user_id=?");
|
||||
$this->selectAllStmt = self::$PDO->prepare(
|
||||
"SELECT user_id, street, zipcode FROM din_useraddressno");
|
||||
$this->updateStmt = self::$PDO->prepare(
|
||||
"UPDATE din_useraddressno SET
|
||||
street=?,
|
||||
zipcode=?,
|
||||
WHERE user_id=?");
|
||||
$this->insertStmt = self::$PDO->prepare(
|
||||
"INSERT INTO din_useraddressno (
|
||||
user_id, street, zipcode
|
||||
) values (?, ?, ?)");
|
||||
$this->deleteStmt = self::$PDO->prepare(
|
||||
"DELETE FROM din_useraddressno WHERE user_id=?");
|
||||
$this->findByUserIdStmt = self::$PDO->prepare(
|
||||
"SELECT user_id, street, zipcode FROM din_useraddressno WHERE user_id=?");
|
||||
}
|
||||
|
||||
protected function doCreateObject(array $array) {
|
||||
$obj = new domain_Membership($array["user_id"]);
|
||||
|
||||
$user_mapper = new mapper_UserMapper();
|
||||
$obj->setUser($user_mapper->find($array["user_id"]));
|
||||
|
||||
$obj->setStreet($array["street"]);
|
||||
$obj->setZipCode($array["zipcode"]);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
protected function doInsert(domain_DomainObject $object) {
|
||||
$values = array($object->getUser()->getId(), $object->getStreet(), $object->getZipCode());
|
||||
$this->insertStmt->execute($values);
|
||||
$id = self::$PDO->lastInsertId();
|
||||
$object->setId($id);
|
||||
}
|
||||
|
||||
function update(domain_DomainObject $object) {
|
||||
$values = array(
|
||||
$object->getStreet(),
|
||||
$object->getZipCode(),
|
||||
$object->getId()
|
||||
);
|
||||
$this->updateStmt->execute($values);
|
||||
}
|
||||
|
||||
protected function doDelete(domain_DomainObject $object) {
|
||||
$values = array($object->getId());
|
||||
$this->deleteStmt->execute($values);
|
||||
}
|
||||
|
||||
function selectStmt() {
|
||||
return $this->selectStmt;
|
||||
}
|
||||
|
||||
function selectAllStmt() {
|
||||
return $this->selectAllStmt;
|
||||
}
|
||||
|
||||
function deleteStmt() {
|
||||
return $this->deleteStmt;
|
||||
}
|
||||
|
||||
function findByUserId($userid) {
|
||||
$this->findByUserIdStmt->execute(array($userid));
|
||||
return new mapper_UserAddressCollection($this->findByUserIdStmt->fetchAll(), $this);
|
||||
}
|
||||
|
||||
function getCollection(array $raw) {
|
||||
return new mapper_UserAddressCollection($raw, $this);
|
||||
}
|
||||
|
||||
protected function targetClass() {
|
||||
return "domain_UserAddress";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* User collection - collection of elements in the user database
|
||||
*
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class mapper_UserCollection extends mapper_Collection {
|
||||
function targetClass() {
|
||||
return "domain_User";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* User object mapper to database
|
||||
*
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class mapper_UserMapper extends mapper_Mapper {
|
||||
|
||||
function __construct() {
|
||||
// initialize database connection and common setup
|
||||
parent::__construct();
|
||||
|
||||
// prepare SQL statements
|
||||
$this->selectStmt = self::$PDO->prepare(
|
||||
"SELECT * FROM din_user WHERE id=?");
|
||||
$this->selectAllStmt = self::$PDO->prepare(
|
||||
"SELECT * FROM din_user");
|
||||
$this->updateStmt = self::$PDO->prepare(
|
||||
"UPDATE din_user SET
|
||||
username=?,
|
||||
password=?,
|
||||
firstname=?,
|
||||
lastname=?,
|
||||
addresstype='no',
|
||||
valid_address=?,
|
||||
email=?,
|
||||
birthdate=?,
|
||||
placeOfStudy=?,
|
||||
passwordReset=?,
|
||||
division_id_request=?
|
||||
WHERE id=?");
|
||||
$this->insertStmt = self::$PDO->prepare(
|
||||
"INSERT INTO din_user (
|
||||
username
|
||||
) values (?)");
|
||||
$this->deleteStmt = self::$PDO->prepare(
|
||||
"DELETE FROM din_user WHERE id=?");
|
||||
}
|
||||
|
||||
protected function doCreateObject(array $array) {
|
||||
$obj = new domain_User($array["id"]);
|
||||
$obj->setUsername($array["username"]);
|
||||
$obj->setPassword($array["password"]);
|
||||
$obj->setFirstname($array["firstname"]);
|
||||
$obj->setLastname($array["lastname"]);
|
||||
$obj->setValidaddress($array["valid_address"]);
|
||||
$obj->setEmail($array["email"]);
|
||||
$obj->setBirthdate($array["birthdate"]);
|
||||
$obj->setPlaceOfStudy($array["placeOfStudy"]);
|
||||
$obj->setPasswordreset($array["passwordReset"]);
|
||||
$obj->setDivisionIdRequest($array["division_id_request"]);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
protected function doInsert(domain_DomainObject $object) {
|
||||
$values = array($object->getUsername());
|
||||
//$this->insertStmt->execute($values);
|
||||
$id = self::$PDO->lastInsertId();
|
||||
$object->setId($id);
|
||||
}
|
||||
|
||||
function update(domain_DomainObject $object) {
|
||||
$values = array(
|
||||
$object->getUsername(),
|
||||
$object->getPassword(),
|
||||
$object->getFirstname(),
|
||||
$object->getLastname(),
|
||||
$object->getValidAddress(),
|
||||
$object->getEmail(),
|
||||
$object->getBirthdate(),
|
||||
$object->getPlaceOfStudy(),
|
||||
$object->getPasswordreset(),
|
||||
$object->getDivisionIdRequest(),
|
||||
$object->getId()
|
||||
);
|
||||
print_r($values);
|
||||
//$this->updateStmt->execute($values);
|
||||
}
|
||||
|
||||
protected function doDelete(domain_DomainObject $object) {
|
||||
$values = array($object->getId());
|
||||
$this->deleteStmt->execute($values);
|
||||
}
|
||||
|
||||
function selectStmt() {
|
||||
return $this->selectStmt;
|
||||
}
|
||||
|
||||
function selectAllStmt() {
|
||||
return $this->selectAllStmt;
|
||||
}
|
||||
|
||||
function deleteStmt() {
|
||||
return $this->deleteStmt;
|
||||
}
|
||||
|
||||
function getCollection(array $raw) {
|
||||
return new mapper_UserCollection($raw, $this);
|
||||
}
|
||||
|
||||
protected function targetClass() {
|
||||
return "domain_User";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* User updates collection - collection of elements in the user database
|
||||
*
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class mapper_UserUpdateCollection extends mapper_Collection {
|
||||
function targetClass() {
|
||||
return "domain_UserUpdate";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* User object mapper to database
|
||||
*
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class mapper_UserUpdateMapper extends mapper_Mapper {
|
||||
|
||||
function __construct() {
|
||||
// initialize database connection and common setup
|
||||
parent::__construct();
|
||||
|
||||
// prepare SQL statements
|
||||
$this->selectStmt = self::$PDO->prepare(
|
||||
"SELECT * FROM din_userupdate WHERE id=?");
|
||||
$this->selectAllStmt = self::$PDO->prepare(
|
||||
"SELECT * FROM din_userupdate");
|
||||
$this->findByUserIdStmt = self::$PDO->prepare(
|
||||
"SELECT * FROM din_userupdate WHERE user_id_updated=?");
|
||||
$this->updateStmt = self::$PDO->prepare(
|
||||
"UPDATE din_userupdate SET
|
||||
date=?,
|
||||
user_id_updated=?,
|
||||
comment=?,
|
||||
user_id_updated_by=?
|
||||
WHERE id=?");
|
||||
$this->insertStmt = self::$PDO->prepare(
|
||||
"INSERT INTO din_userupdate (
|
||||
date, user_id_updated, comment, user_id_updated_by
|
||||
) values (?,?,?,?)");
|
||||
$this->deleteStmt = self::$PDO->prepare(
|
||||
"DELETE FROM din_userupdate WHERE id=?");
|
||||
}
|
||||
|
||||
protected function doCreateObject(array $array) {
|
||||
$obj = new domain_UserUpdate($array["id"]);
|
||||
$obj->setDate($array["date"]);
|
||||
$obj->setUser($array["user_id_updated"]);
|
||||
$obj->setMessage($array["comment"]);
|
||||
$obj->setUpdatedBy($array["user_id_updated_By"]);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
protected function doInsert(domain_DomainObject $object) {
|
||||
$values = array($object->getUsername());
|
||||
//$this->insertStmt->execute($values);
|
||||
$id = self::$PDO->lastInsertId();
|
||||
$object->setId($id);
|
||||
}
|
||||
|
||||
function update(domain_DomainObject $object) {
|
||||
$values = array(
|
||||
$object->getDate(),
|
||||
$object->getUser(),
|
||||
$object->getMessage(),
|
||||
$object->getUpdatedBy(),
|
||||
$object->getId()
|
||||
);
|
||||
print_r($values);
|
||||
$this->updateStmt->execute($values);
|
||||
}
|
||||
|
||||
protected function doDelete(domain_DomainObject $object) {
|
||||
$values = array($object->getId());
|
||||
$this->deleteStmt->execute($values);
|
||||
}
|
||||
|
||||
function selectStmt() {
|
||||
return $this->selectStmt;
|
||||
}
|
||||
|
||||
function selectAllStmt() {
|
||||
return $this->selectAllStmt;
|
||||
}
|
||||
|
||||
function deleteStmt() {
|
||||
return $this->deleteStmt();
|
||||
}
|
||||
|
||||
function findByUserId($userid) {
|
||||
$this->findByUserIdStmt->execute(array($userid));
|
||||
return new mapper_UserUpdateCollection($this->findByUserIdStmt->fetchAll(), $this);
|
||||
}
|
||||
|
||||
function getCollection(array $raw) {
|
||||
return new mapper_UserCollection($raw, $this);
|
||||
}
|
||||
|
||||
protected function targetClass() {
|
||||
return "domain_UserUpdate";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user