Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Customer.class.php
- function getByName($name) {
- // SELECT * FROM `customer` WHERE `name` = $name
- }
- // ** this could instead be written as: **
- // ORM.class.php
- function getByField($field, $value) {
- // SELECT * FROM `$this->table` WHERE `$field` = $value
- }
- // Customer.class.php
- function getByName($name) {
- // SELECT * FROM `customer` WHERE `name` = $name
- }
- // ** this could instead be written as: **
- // ORM.class.php
- function getByField($field, $value) {
- // SELECT * FROM `$this->table` WHERE `$field` = $value
- }
- class Customer {
- public $name;
- public function save() {
- $orm = new ORM('customers', 'id'); // table name and primary key
- $orm->name = $this->name;
- $orm->save();
- }
- }
- class Poll extends dbObject // dbObject is my ORM. Poll can extend it so it gets all properties.
- {
- function __construct($ID=false)
- {
- $this->__setupDatabase('polls', // db table
- array('ID_Poll' => 'ID', // db field => object property
- 'strPollQuestion' => 'strpollquestion',
- 'datPublished' => 'datpublished',
- 'datCloseDate' => 'datclosedate',
- 'enmClosed' => 'enmclosed',
- 'enmGoedgekeurd' => 'enmgoedgekeurd'),
- 'ID_Poll', // primary db key
- $ID); // primary key value
- $this->addRelation('Pollitem'); //Connect PollItem to Poll 1;1
- $this->addRelation('Pollvote', 'PollUser'); // connect pollVote via PollUser (many:many)
- }
- function Display()
- {
- // do your displayíng for poll here:
- $pollItems = $this->Find("PollItem"); // find all poll items
- $alreadyvoted = $this->Find("PollVote", array("IP"=>$_SERVER['REMOTE_ADDR'])); // find all votes for current ip
- }
Add Comment
Please, Sign In to add comment