flush
[m6w6/pq-gateway] / lib / pq / Gateway / Cell.php
index b284b75a7d98b7205f70bf3c54f1fc3487e7cf76..efa5fcbb3cd1154ecd99321bdddaf9e093a7a5c2 100644 (file)
@@ -2,9 +2,9 @@
 
 namespace pq\Gateway;
 
 
 namespace pq\Gateway;
 
-use \pq\Query\Expr;
+use \pq\Query\Expressible;
 
 
-class Cell
+class Cell extends Expressible
 {
        /**
         * @var \pq\Gateway\Row
 {
        /**
         * @var \pq\Gateway\Row
@@ -16,11 +16,6 @@ class Cell
         */
        protected $name;
        
         */
        protected $name;
        
-       /**
-        * @var mixed
-        */
-       protected $data;
-       
        /**
         * @var bool
         */
        /**
         * @var bool
         */
@@ -33,28 +28,12 @@ class Cell
         * @param bool $dirty
         */
        function __construct(Row $row, $name, $data, $dirty = false) {
         * @param bool $dirty
         */
        function __construct(Row $row, $name, $data, $dirty = false) {
+               parent::__construct($data);
                $this->row = $row;
                $this->name = $name;
                $this->row = $row;
                $this->name = $name;
-               $this->data = $data;
                $this->dirty = $dirty;
        }
        
                $this->dirty = $dirty;
        }
        
-       /**
-        * Get value as string
-        * @return string
-        */
-       function __toString() {
-               return (string) $this->data;
-       }
-       
-       /**
-        * Test whether the value is an unevaluated expression
-        * @return bool
-        */
-       function isExpr() {
-               return $this->data instanceof Expr;
-       }
-       
        /**
         * Check whether the cell has been modified
         * @return bool
        /**
         * Check whether the cell has been modified
         * @return bool
@@ -64,46 +43,26 @@ class Cell
        }
        
        /**
        }
        
        /**
-        * Get value
-        * @return mixed
-        */
-       function get() {
-               return $this->data;
-       }
-       
-       /**
-        * Modify the value in this cell
+        * Set the value
         * @param mixed $data
         * @param mixed $data
-        * @param string $op a specific operator
         * @return \pq\Gateway\Cell
         */
         * @return \pq\Gateway\Cell
         */
-       function mod($data, $op = null) {
-               if (!($this->data instanceof Expr)) {
-                       $this->data = new Expr($this->name);
-               }
-               
-               if ($data instanceof Expr) {
-                       $this->data->add($data);
-               } elseif (!isset($op) && is_numeric($data)) {
-                       $this->data->add(new Expr("+ $data"));
-               } else {
-                       $data = $this->row->getTable()->getConnection()->quote($data);
-                       $this->data->add(new Expr("%s %s", isset($op) ? $op : "||", $data));
-               }
-               
+       function set($data) {
+               parent::set($data);
                $this->dirty = true;
                $this->dirty = true;
-               
                return $this;
        }
        
        /**
                return $this;
        }
        
        /**
-        * Set the value in this cell
+        * Modify the value in this cell
         * @param mixed $data
         * @param mixed $data
+        * @param string $op a specific operator
         * @return \pq\Gateway\Cell
         */
         * @return \pq\Gateway\Cell
         */
-       function set($data) {
-               $this->data = $data;
+       function mod($data, $op = null) {
+               parent::mod($data, $op);
                $this->dirty = true;
                return $this;
        }
                $this->dirty = true;
                return $this;
        }
+       
 }
 }