public function compareColumns($column1, $column2, $partial = false, $link = 'AND') {
        $this->conditionColumns[] = $column2;
        $this->conditionColumns[] = $column1;
        if (is_array($column2)) {
            foreach ($column2 as &$col)
                $col = $this->_column($col);
            return $this->addCondition($this->_column($column1) . ' IN (' . implode(', ', $column2) . ')', array(), $link);
        }
        if ($partial) {
            return $this->addCondition($this->_column($column1) . ' LIKE CONCAT("%", ' . $this->_column($column2) . ' , "%")', array(), $link);
        }
        $operators = array('>=', '<=', '!=', '>', '<');
        $matched = false;
        foreach ($operators as $operator) {
            if ($operator == substr($column2, 0, strlen($operator))) {
                $column2 = trim(substr($column2, strlen($operator)));
                $matched = true;
                break;
            }
        }
        $operator = $matched ? $operator : '=';
        return $this->addCondition($this->_column($column1) . ' ' . $operator . ' ' . $this->_column($column2), array(), $link);
    }
public function compareColumns($column1, $column2, $partial = false, $link = 'AND') {
        $this->conditionColumns[] = $column2;
        $this->conditionColumns[] = $column1;
        if (is_array($column2)) {
            foreach ($column2 as &$col)
                $col = $this->_column($col);
            return $this->addCondition($this->_column($column1) . ' IN (' . implode(', ', $column2) . ')', array(), $link);
        }
        if ($partial) {
            return $this->addCondition($this->_column($column1) . ' LIKE CONCAT("%", ' . $this->_column($column2) . ' , "%")', array(), $link);
        }
        $operators = array('>=', '<=', '!=', '>', '<');
        $matched = false;
        foreach ($operators as $operator) {
            if ($operator == substr($column2, 0, strlen($operator))) {
                $column2 = trim(substr($column2, strlen($operator)));
                $matched = true;
                break;
            }
        }
        $operator = $matched ? $operator : '=';
        return $this->addCondition($this->_column($column1) . ' ' . $operator . ' ' . $this->_column($column2), array(), $link);
    }
public function compareColumns ( $ column1 , $ column2 , $ partial = false , $ link = 'AND' ) { $ this -> conditionColumns [ ] = $ column2 ; $ this -> conditionColumns [ ] = $ column1 ; if ( is_array ( $ column2 ) ) { foreach ( $ column2 as & $ col ) $ col = $ this -> _column ( $ col ) ; return $ this -> addCondition ( $ this -> _column ( $ column1 ) . ' IN (' . implode ( ', ' , $ column2 ) . ')' , array ( ) , $ link ) ; } if ( $ partial ) { return $ this -> addCondition ( $ this -> _column ( $ column1 ) . ' LIKE CONCAT("%", ' . $ this -> _column ( $ column2 ) . ' , "%")' , array ( ) , $ link ) ; } $ operators = array ( '>=' , '<=' , '!=' , '>' , '<' ) ; $ matched = false ; foreach ( $ operators as $ operator ) { if ( $ operator == substr ( $ column2 , 0 , strlen ( $ operator ) ) ) { $ column2 = trim ( substr ( $ column2 , strlen ( $ operator ) ) ) ; $ matched = true ; break ; } } $ operator = $ matched ? $ operator : '=' ; return $ this -> addCondition ( $ this -> _column ( $ column1 ) . ' ' . $ operator . ' ' . $ this -> _column ( $ column2 ) , array ( ) , $ link ) ; }
Same as compareColumn but instead of value another column is used.

Example:

[php]
$condition->compareColumn('name', 'firstname'); // simple comparison with exact value of the columns.
//   Result: "`tableName`.`name` = `tableName`.`firstName`"
$condition->compareColumn('name', array('fname', 'lname')); // compare with multiple columns;
//   Result: "`tableName`.`name` IN (`tableName`.`fname`, `tableName`.`lname`)"
$condition->compareColumn('age', '>=fname'); // must be equal or bigger than selected column
//    Result: "`tableName`.`age` >= `tableName`.`fname`"
$condition->compareColumn('name', 'fname', true); // partial match
//    Result: "`tableName`.`name` LIKE CONCAT('%', `tableName`.`fname`, '%')"
[/php]
@param string $column1
@param string $column2
@param boolean $partial
@param string $link
@return \mpf\datasources\sql\ModelCondition
Same as compareColumn but instead of value another column is used .