X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fpq-gateway;a=blobdiff_plain;f=lib%2Fpq%2FGateway%2FRow.php;h=cda8d4af67a0ba857a6854b4f8c262f016f5e34d;hp=6d9c19e750b1b215da48b1b90959692f3f6c9fd8;hb=b39e14404cfeac177d41b152690b6adbb2b1e4bf;hpb=3c8b32baaac62855e2c9f5bfdb5ede9685ce2b76 diff --git a/lib/pq/Gateway/Row.php b/lib/pq/Gateway/Row.php index 6d9c19e..cda8d4a 100644 --- a/lib/pq/Gateway/Row.php +++ b/lib/pq/Gateway/Row.php @@ -184,6 +184,18 @@ class Row implements \JsonSerializable return $changes; } + /** + * Cell accessor + * @param string $p column name + * @return \pq\Gateway\Cell + */ + protected function cell($p) { + if (!isset($this->cell[$p])) { + $this->cell[$p] = new Cell($this, $p, isset($this->data[$p]) ? $this->data[$p] : null); + } + return $this->cell[$p]; + } + /** * Get a cell or parent rows * @param string $p @@ -193,10 +205,7 @@ class Row implements \JsonSerializable if ($this->table->hasRelation($p)) { return $this->table->by($this, $p); } - if (!isset($this->cell[$p])) { - $this->cell[$p] = new Cell($this, $p, isset($this->data[$p]) ? $this->data[$p] : null); - } - return $this->cell[$p]; + return $this->cell($p); } /** @@ -205,7 +214,7 @@ class Row implements \JsonSerializable * @param mixed $v */ function __set($p, $v) { - $this->__get($p)->set($v); + $this->cell($p)->set($v); } /**