From 002783858d3a859b1bbae977cc6db4ed13ca0187 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 15 Oct 2014 17:21:42 +0200 Subject: [PATCH] manage properties where they belong --- lib/pq/Gateway/Cell.php | 11 ++++------- lib/pq/Query/Expressible.php | 15 +++++++++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/pq/Gateway/Cell.php b/lib/pq/Gateway/Cell.php index 3c69a12..ab2a46f 100644 --- a/lib/pq/Gateway/Cell.php +++ b/lib/pq/Gateway/Cell.php @@ -11,11 +11,6 @@ class Cell extends Expressible implements \ArrayAccess */ protected $row; - /** - * @var string - */ - protected $name; - /** * @var bool */ @@ -28,9 +23,8 @@ class Cell extends Expressible implements \ArrayAccess * @param bool $dirty */ function __construct(Row $row, $name, $data, $dirty = false) { - parent::__construct($data); + parent::__construct($name, $data); $this->row = $row; - $this->name = $name; $this->dirty = $dirty; } @@ -68,6 +62,9 @@ class Cell extends Expressible implements \ArrayAccess * @return \pq\Gateway\Cell */ function mod($data, $op = null) { + if (is_string($data)) { + $data = $this->row->getTable()->getConnection()->quote($data); + } parent::mod($data, $op); $this->dirty = true; return $this; diff --git a/lib/pq/Query/Expressible.php b/lib/pq/Query/Expressible.php index dc2db66..d123d8d 100644 --- a/lib/pq/Query/Expressible.php +++ b/lib/pq/Query/Expressible.php @@ -4,12 +4,22 @@ namespace pq\Query; class Expressible implements ExpressibleInterface { + /** + * @var string + */ + protected $name; + /** * @var mixed */ protected $data; - function __construct($data) { + /** + * @param string $name + * @param mixed $data + */ + function __construct($name, $data) { + $this->name = $name; $this->data = $data; } @@ -63,9 +73,6 @@ class Expressible implements ExpressibleInterface } elseif (!isset($op) && is_numeric($data)) { $this->data->add(new Expr("+ $data")); } else { - if (!is_array($data)) { - $data = $this->row->getTable()->getConnection()->quote($data); - } $this->data->add(new Expr("%s %s", isset($op) ? $op : "||", $data)); } -- 2.30.2