My favorites | Sign in
Project Logo
                
Search
for
Updated Sep 12, 2007 by VaultedCeilings
Labels: Phase-Deploy, Phase-Support
WriteDataObjects  
How to write a data object for use with Junction

Junction Quick-start

Writing a data object for Junction

After saving your mapping file it's time to create a data object. Junction operates on ordinary PHP objects -- which means you can extend, implement what you will, and that you can write whatever methods you want. That said there are two requirements placed on the data object by Junction.

  1. a public getX and setX method for each property defined in the mapping file.
  2. there is a public constructor with no (or default) parameters.
So, using our running example we'll create a class named JunctionUser with getters and setters for the four defined properties. It doesn't actually matter where this class file resides in your application, but for this project let's place it under /Domain/JunctionUser.php.

Sample data object

class JunctionUser {
	
	private $_id;
	
	private $_email;
	
	private $_password;
	
	private $_created;
	
	public function __construct() {
	
	}
	
	public function getId() {
		return $this->_id;
	}
	
	public function setId($id) {
		$this->_id = $id;
	}
	
	public function getEmail() {
		return $this->_email;
	}
	
	public function setEmail($email) {
		$this->_email = $email;
	}
	
	public function getPassword() {
		return $this->_password;
	}
	
	public function setPassword($password) {
		$this->_password = $password;
	}
	
	public function getDate() {
		return $this->_created;
	}
	
	public function setDate($date) {
		$this->_created = $date;
	}
}

Go on to PerformCrud, or back to the JunctionQuickStart


Sign in to add a comment
Hosted by Google Code