src/Common/CodeIgniter/Libraries/FormValidation.php
public function unique_if_diff($new, $params)
    {
        list($table, $column, $old) = explode(".", $params, 3);

        if ($new == $old) {
            return true;
        }

        if (!array_key_exists('unique_if_diff', $this->_error_messages)) {
            $this->set_message('unique_if_diff', lang('fv_unique_if_diff_field'));
        }

        $oDb = Factory::service('Database');
        $oDb->where($column . ' !=', $old);
        $oDb->where($column, $new);
        $oDb->limit(1);
        $q = $oDb->get($table);

        if ($q->row()) {
            return false;
        }

        return true;
    }
public function unique_if_diff($new, $params)
    {
        list($table, $column, $old) = explode(".", $params, 3);

        if ($new == $old) {
            return true;
        }

        if (!array_key_exists('unique_if_diff', $this->_error_messages)) {
            $this->set_message('unique_if_diff', lang('fv_unique_if_diff_field'));
        }

        $oDb = Factory::service('Database');
        $oDb->where($column . ' !=', $old);
        $oDb->where($column, $new);
        $oDb->limit(1);
        $q = $oDb->get($table);

        if ($q->row()) {
            return false;
        }

        return true;
    }
public function unique_if_diff ( $ new , $ params ) { list ( $ table , $ column , $ old ) = explode ( "." , $ params , 3 ) ; if ( $ new == $ old ) { return true ; } if ( ! array_key_exists ( 'unique_if_diff' , $ this -> _error_messages ) ) { $ this -> set_message ( 'unique_if_diff' , lang ( 'fv_unique_if_diff_field' ) ) ; } $ oDb = Factory :: service ( 'Database' ) ; $ oDb -> where ( $ column . ' !=' , $ old ) ; $ oDb -> where ( $ column , $ new ) ; $ oDb -> limit ( 1 ) ; $ q = $ oDb -> get ( $ table ) ; if ( $ q -> row ( ) ) { return false ; } return true ; }
Checks if a certain value is unique in a specified table if different
from current value.

@param string $new    The form value
@param string $params Parameters passed from set_rules() method

@return boolean
Checks if a certain value is unique in a specified table if different from current value .