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
) {
59 * Modify the value in this cell
61 * @param string $op a specific operator
62 * @return \pq\Gateway\Cell
64 function mod($data, $op = null) {
65 if (is_string($data)) {
66 $data = $this->row
->getTable()->getConnection()->quote($data);
68 parent
::mod($data, $op);
73 function offsetGet($o) {
74 if (isset($this->data
) && !is_array($this->data
)) {
75 throw new \
UnexpectedValueException("Cell data is not an array");
77 return $this->data
[$o];
80 function offsetSet($o, $v) {
81 if (isset($this->data
) && !is_array($this->data
)) {
82 throw new \
UnexpectedValueException("Cell data is not an array");
92 function offsetExists($o) {
93 if (isset($this->data
) && !is_array($this->data
)) {
94 throw new \
UnexpectedValueException("Cell data is not an array");
96 return isset($this->data
[$o]);
99 function offsetUnset($o) {
100 if (isset($this->data
) && !is_array($this->data
)) {
101 throw new \
UnexpectedValueException("Cell data is not an array");
103 unset($this->data
[$o]);