Esempio n. 1
0
 protected function execute()
 {
     if (!isset($this->rows)) {
         $referencing =& $this->result->referencing[$this->__toString()];
         if (!isset($referencing)) {
             if (!$this->limit || count($this->result->rows) <= 1 || $this->union) {
                 parent::execute();
             } else {
                 //! doesn't work with union
                 $result = clone $this;
                 $first = true;
                 foreach ((array) $this->result->rows as $val) {
                     if ($first) {
                         $result->where[0] = "{$this->column} = " . $this->quote($val);
                         $first = false;
                     } else {
                         $clone = clone $this;
                         $clone->where[0] = "{$this->column} = " . $this->quote($val);
                         $result->union($clone);
                     }
                 }
                 $result->execute();
                 $this->rows = $result->rows;
             }
             $referencing = array();
             foreach ($this->rows as $key => $row) {
                 $referencing[$row[$this->column]][$key] = $row;
             }
         }
         $this->data =& $referencing[$this->active];
         if (!isset($this->data)) {
             $this->data = array();
         }
     }
 }
Esempio n. 2
0
 protected function execute()
 {
     if (!isset($this->rows)) {
         $referencing =& $this->result->referencing[$this->__toString()];
         if (!isset($referencing)) {
             $limit = $this->limit;
             $rows = count($this->result->rows);
             if ($this->limit && $rows > 1) {
                 $this->limit = null;
             }
             parent::execute();
             $this->limit = $limit;
             $referencing = array();
             $offset = array();
             foreach ($this->rows as $key => $row) {
                 $ref =& $referencing[$row[$this->column]];
                 $skip =& $offset[$row[$this->column]];
                 if (!isset($limit) || $rows <= 1 || count($ref) < $limit && $skip >= $this->offset) {
                     $ref[$key] = $row;
                 } else {
                     unset($this->rows[$key]);
                 }
                 $skip++;
                 unset($ref, $skip);
             }
         }
         $this->data =& $referencing[$this->active];
         if (!isset($this->data)) {
             $this->data = array();
         }
     }
 }