View difference between Paste ID: JPW1dyci and RtNQbaRB
SHOW: | | - or go back to the newest paste.
1
<?php
2
// WHEEL CLASSES
3
class Wheel {
4
	public $id;
5
	public $radius;
6
	public $grip;
7
}
8
class WheelMapper {
9
	public $pdo;
10
	
11
	public function __constructor($pdo) {
12
		$this->pdo = $pdo;
13
	}
14
	
15
	public function fetch($wheelCollection) {
16
		$result = $this->pdo-> Query table `wheels` where `car_id` = $wheel->id
17
	}
18
}
19-
class wheelCollection {
19+
class WheelCollection {
20
	
21
}
22
23
// CAR CLASSES
24
class Car {
25
	public $id;
26
	public $make;
27
	public $model;
28
	public $wheels;
29
	
30
	public function setId($car_id) {
31
		$this->id = $car_id;
32
	}
33
	
34
	public function addWheels($wheels) {
35
		$this->wheels = $wheels;
36
	}
37
	
38
	public function getWheelType() {
39
		
40
	}
41
}
42
class carMapper {
43
	public $pdo;
44
	
45
	public function __constructor($pdo) {
46
		$this->pdo = $pdo;
47
	}
48
	
49
	public function fetch($car) {
50
		$result = $this->pdo-> Query table `cars` where `car_id` = $car->id
51
		$car->make = $result['make'];
52
		$car->model = $result['model'];
53
	}
54
}
55
56
$car = new Car;
57
$car->setId(42);
58
$mapper = new CarMapper($pdo);
59
if ( $mapper->fetch($car) ) //if there was a car in DB
60
{
61
    $wheels = new WheelCollection;
62
    $otherMapper = new WheelMapper( $pdo );
63
64
    $car->addWheels( $wheels );
65
66
    $wheels->setType($car->getWheelType());
67
    // I am not a mechanic. There is probably some name for describing 
68
    // wheels that a car can use
69
    $otherMapper->fetch( $wheels );
70
}
71
72
?>