3667854430f1848fe844040457c4aff3e20d93fa
5 use \pq\Query\Expressible
;
7 class Cell
extends Expressible
implements \ArrayAccess
10 * @var \pq\Gateway\Row
20 * @param \pq\Gateway\Row $row
25 function __construct(Row
$row, $name, $data, $dirty = false) {
26 parent
::__construct($name, $data);
28 $this->dirty
= $dirty;
32 * Check whether the cell has been modified
36 return (bool) $this->dirty
;
42 * @return \pq\Gateway\Cell
45 if ($data instanceof Row
) {
46 $this->row
->__set($data->getTable()->getName() . "_id", $data->id
);
47 $this->row
->__unset($this->name
);
50 if ($data instanceof Cell
) {
53 if ($this->data
!== $data) {
61 * Modify the value in this cell
63 * @param string $op a specific operator
64 * @return \pq\Gateway\Cell
66 function mod($data, $op = null) {
67 if (is_string($data)) {
68 $data = $this->row
->getTable()->getConnection()->quote($data);
70 parent
::mod($data, $op);
75 function offsetGet($o) {
76 if (isset($this->data
) && !is_array($this->data
)) {
77 throw new \
UnexpectedValueException("Cell data is not an array");
79 return $this->data
[$o];
82 function offsetSet($o, $v) {
83 if (isset($this->data
) && !is_array($this->data
)) {
84 throw new \
UnexpectedValueException("Cell data is not an array");
94 function offsetExists($o) {
95 if (isset($this->data
) && !is_array($this->data
)) {
96 throw new \
UnexpectedValueException("Cell data is not an array");
98 return isset($this->data
[$o]);
101 function offsetUnset($o) {
102 if (isset($this->data
) && !is_array($this->data
)) {
103 throw new \
UnexpectedValueException("Cell data is not an array");
105 unset($this->data
[$o]);