use \pq\Query\Expressible;
-class Cell extends Expressible
+class Cell extends Expressible implements \ArrayAccess
{
/**
* @var \pq\Gateway\Row
* @return bool
*/
function isDirty() {
- return $this->dirty;
+ return (bool) $this->dirty;
}
/**
* @return \pq\Gateway\Cell
*/
function set($data) {
+ if ($data instanceof Row) {
+ $this->row->__set($data->getTable()->getName() . "_id", $data->id);
+ $this->row->__unset($this->name);
+ return $this;
+ }
+ if ($data instanceof Cell) {
+ $data = $data->get();
+ }
parent::set($data);
$this->dirty = true;
return $this;
return $this;
}
+ function offsetGet($o) {
+ if (isset($this->data) && !is_array($this->data)) {
+ throw new \UnexpectedValueException("Cell data is not an array");
+ }
+ return $this->data[$o];
+ }
+
+ function offsetSet($o, $v) {
+ if (isset($this->data) && !is_array($this->data)) {
+ throw new \UnexpectedValueException("Cell data is not an array");
+ }
+ if (isset($o)) {
+ $this->data[$o] = $v;
+ } else {
+ $this->data[] = $v;
+ }
+ $this->dirty = true;
+ }
+
+ function offsetExists($o) {
+ if (isset($this->data) && !is_array($this->data)) {
+ throw new \UnexpectedValueException("Cell data is not an array");
+ }
+ return isset($this->data[$o]);
+ }
+
+ function offsetUnset($o) {
+ if (isset($this->data) && !is_array($this->data)) {
+ throw new \UnexpectedValueException("Cell data is not an array");
+ }
+ unset($this->data[$o]);
+ $this->dirty = true;
+ }
}