import poc
[m6w6/pq-gateway] / lib / pq / Gateway / Row.php
1 <?php
2
3 namespace pq\Gateway;
4
5 class Row
6 {
7 /**
8 * @var \pq\Gateway\Table
9 */
10 protected $table;
11
12 /**
13 * @var array
14 */
15 protected $data;
16
17 /**
18 * @var array
19 */
20 protected $mods = array();
21
22 /**
23 * @param \pq\Gateway\Table $table
24 * @param array $data
25 */
26 function __construct(Table $table, array $data = null) {
27 $this->table = $table;
28 $this->data = $data;
29 }
30
31 function __get($p) {
32 if (!isset($this->mod[$p])) {
33 $this->mod[$p] = new Cell($this, $p);
34 }
35 return $this->mod[$p];
36 }
37
38 function create() {
39 $this->data = $this->table->create($this->mods)->getIterator()->current()->data;
40 $this->mods = array();
41 return $this;
42 }
43
44 function update() {
45 $this->data = $this->table->update($this->data, $this->mods)->getIterator()->current()->data;
46 $this->mods = array();
47 return $this;
48 }
49
50 function delete() {
51 $this->data = $this->table->delete($this->data, "*")->getIterator()->current()->data;
52 $this->mods = array();
53 return $this;
54 }
55 }