efa5fcbb3cd1154ecd99321bdddaf9e093a7a5c2
[m6w6/pq-gateway] / lib / pq / Gateway / Cell.php
1 <?php
2
3 namespace pq\Gateway;
4
5 use \pq\Query\Expressible;
6
7 class Cell extends Expressible
8 {
9 /**
10 * @var \pq\Gateway\Row
11 */
12 protected $row;
13
14 /**
15 * @var string
16 */
17 protected $name;
18
19 /**
20 * @var bool
21 */
22 protected $dirty;
23
24 /**
25 * @param \pq\Gateway\Row $row
26 * @param string $name
27 * @param mixed $data
28 * @param bool $dirty
29 */
30 function __construct(Row $row, $name, $data, $dirty = false) {
31 parent::__construct($data);
32 $this->row = $row;
33 $this->name = $name;
34 $this->dirty = $dirty;
35 }
36
37 /**
38 * Check whether the cell has been modified
39 * @return bool
40 */
41 function isDirty() {
42 return $this->dirty;
43 }
44
45 /**
46 * Set the value
47 * @param mixed $data
48 * @return \pq\Gateway\Cell
49 */
50 function set($data) {
51 parent::set($data);
52 $this->dirty = true;
53 return $this;
54 }
55
56 /**
57 * Modify the value in this cell
58 * @param mixed $data
59 * @param string $op a specific operator
60 * @return \pq\Gateway\Cell
61 */
62 function mod($data, $op = null) {
63 parent::mod($data, $op);
64 $this->dirty = true;
65 return $this;
66 }
67
68 }