Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // WHEEL CLASSES
- class Wheel {
- public $id;
- public $radius;
- public $grip;
- }
- class WheelMapper {
- public $pdo;
- public function __constructor($pdo) {
- $this->pdo = $pdo;
- }
- public function fetch($wheelCollection) {
- $result = $this->pdo-> Query table `wheels` where `car_id` = $wheel->id
- }
- }
- class WheelCollection {
- }
- // CAR CLASSES
- class Car {
- public $id;
- public $make;
- public $model;
- public $wheels;
- public function setId($car_id) {
- $this->id = $car_id;
- }
- public function addWheels($wheels) {
- $this->wheels = $wheels;
- }
- public function getWheelType() {
- }
- }
- class carMapper {
- public $pdo;
- public function __constructor($pdo) {
- $this->pdo = $pdo;
- }
- public function fetch($car) {
- $result = $this->pdo-> Query table `cars` where `car_id` = $car->id
- $car->make = $result['make'];
- $car->model = $result['model'];
- }
- }
- $car = new Car;
- $car->setId(42);
- $mapper = new CarMapper($pdo);
- if ( $mapper->fetch($car) ) //if there was a car in DB
- {
- $wheels = new WheelCollection;
- $otherMapper = new WheelMapper( $pdo );
- $car->addWheels( $wheels );
- $wheels->setType($car->getWheelType());
- // I am not a mechanic. There is probably some name for describing
- // wheels that a car can use
- $otherMapper->fetch( $wheels );
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement