Cake\Database\Query::__clone PHP Method

__clone() public method

Will clone all of the expression objects used in each of the clauses, as well as the valueBinder.
public __clone ( ) : void
return void
    public function __clone()
    {
        $this->_iterator = null;
        if ($this->_valueBinder !== null) {
            $this->_valueBinder = clone $this->_valueBinder;
        }
        if ($this->_selectTypeMap !== null) {
            $this->_selectTypeMap = clone $this->_selectTypeMap;
        }
        foreach ($this->_parts as $name => $part) {
            if (empty($part)) {
                continue;
            }
            if (is_array($part)) {
                foreach ($part as $i => $piece) {
                    if ($piece instanceof ExpressionInterface) {
                        $this->_parts[$name][$i] = clone $piece;
                    }
                }
            }
            if ($part instanceof ExpressionInterface) {
                $this->_parts[$name] = clone $part;
            }
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Object clone hook.
  *
  * Destroys the clones inner iterator and clones the value binder, and eagerloader instances.
  *
  * @return void
  */
 public function __clone()
 {
     parent::__clone();
     if ($this->_eagerLoader) {
         $this->_eagerLoader = clone $this->_eagerLoader;
     }
 }