4 * Fake Database. Stores records in $_SESSION
7 public function __construct() {
8 if (!isset($_SESSION['pk'])) {
9 $_SESSION['pk'] = 10; // <-- start fake pks at 10
10 $_SESSION['rs'] = getData(); // <-- populate $_SESSION with data.
14 public function pk() {
15 return $_SESSION['pk']++;
18 public function rs() {
19 return $_SESSION['rs'];
21 public function insert($rec) {
22 array_push($_SESSION['rs'], $rec);
24 public function update($idx, $attributes) {
25 $_SESSION['rs'][$idx] = $attributes;
27 public function destroy($idx) {
28 return array_shift(array_splice($_SESSION['rs'], $idx, 1));
35 array('id' => 1, 'first' => "Fred", 'last' => 'Flintstone', 'email' => 'fred@flintstone.com'),
36 array('id' => 2, 'first' => "Wilma", 'last' => 'Flintstone', 'email' => 'wilma@flintstone.com'),
37 array('id' => 3, 'first' => "Pebbles", 'last' => 'Flintstone', 'email' => 'pebbles@flintstone.com'),
38 array('id' => 4, 'first' => "Barney", 'last' => 'Rubble', 'email' => 'barney@rubble.com'),
39 array('id' => 5, 'first' => "Betty", 'last' => 'Rubble', 'email' => 'betty@rubble.com'),
40 array('id' => 6, 'first' => "BamBam", 'last' => 'Rubble', 'email' => 'bambam@rubble.com')