public function disable($where=null)
    {
        $model = static::getQueryModel();
        
        $deletedField = isset($model['deleted_field']) ? $model['deleted_field'] : (isset($model['fields']['deleted']) ? 'deleted' : null);
        if (!$deletedField) {
            return ErrorInfo::error('deleted filed is not exists.');
        }
        
        $data[] = "$deletedField = ($deletedField + 1) % 2";
        $deleteTimeField = isset($model['fields']['delete_time']) ? 'delete_time' : null;
        if ($deleteTimeField) {
            $data[$deleteTimeField] = time();
        }
        if ($where) {
            $this->getQuery()->where($where);
        }
        $mwhere = $this->getQuery()->get('where');
        
        $res = $this->update()->set($data)->query();
        
        // cache flush current model, 当实际表的操作类不是当前类或和当前类是同一个表的类时才更新，避免了 getQueryModel()和this 是同一个类但实例化的表不一样
        if ($this['table_name'] == $model['table_name']) {
            if (is_numeric($where)) {
                $model->cacheFlushByRecord([$model['primary_key'] => $where]);
            } elseif ($mwhere) {
                $model->cacheFlushByRecord($mwhere);
            }
        }
        
        return ErrorInfo::instance($res === false ? -1 : 0);
    }
public function disable($where=null)
    {
        $model = static::getQueryModel();
        
        $deletedField = isset($model['deleted_field']) ? $model['deleted_field'] : (isset($model['fields']['deleted']) ? 'deleted' : null);
        if (!$deletedField) {
            return ErrorInfo::error('deleted filed is not exists.');
        }
        
        $data[] = "$deletedField = ($deletedField + 1) % 2";
        $deleteTimeField = isset($model['fields']['delete_time']) ? 'delete_time' : null;
        if ($deleteTimeField) {
            $data[$deleteTimeField] = time();
        }
        if ($where) {
            $this->getQuery()->where($where);
        }
        $mwhere = $this->getQuery()->get('where');
        
        $res = $this->update()->set($data)->query();
        
        // cache flush current model, 当实际表的操作类不是当前类或和当前类是同一个表的类时才更新，避免了 getQueryModel()和this 是同一个类但实例化的表不一样
        if ($this['table_name'] == $model['table_name']) {
            if (is_numeric($where)) {
                $model->cacheFlushByRecord([$model['primary_key'] => $where]);
            } elseif ($mwhere) {
                $model->cacheFlushByRecord($mwhere);
            }
        }
        
        return ErrorInfo::instance($res === false ? -1 : 0);
    }
public function disable ( $ where = null ) { $ model = static :: getQueryModel ( ) ; $ deletedField = isset ( $ model [ 'deleted_field' ] ) ? $ model [ 'deleted_field' ] : ( isset ( $ model [ 'fields' ] [ 'deleted' ] ) ? 'deleted' : null ) ; if ( ! $ deletedField ) { return ErrorInfo :: error ( 'deleted filed is not exists.' ) ; } $ data [ ] = "$deletedField = ($deletedField + 1) % 2" ; $ deleteTimeField = isset ( $ model [ 'fields' ] [ 'delete_time' ] ) ? 'delete_time' : null ; if ( $ deleteTimeField ) { $ data [ $ deleteTimeField ] = time ( ) ; } if ( $ where ) { $ this -> getQuery ( ) -> where ( $ where ) ; } $ mwhere = $ this -> getQuery ( ) -> get ( 'where' ) ; $ res = $ this -> update ( ) -> set ( $ data ) -> query ( ) ; // cache flush current model, 当实际表的操作类不是当前类或和当前类是同一个表的类时才更新，避免了 getQueryModel()和this 是同一个类但实例化的表不一样 if ( $ this [ 'table_name' ] == $ model [ 'table_name' ] ) { if ( is_numeric ( $ where ) ) { $ model -> cacheFlushByRecord ( [ $ model [ 'primary_key' ] => $ where ] ) ; } elseif ( $ mwhere ) { $ model -> cacheFlushByRecord ( $ mwhere ) ; } } return ErrorInfo :: instance ( $ res === false ? - 1 : 0 ) ; }
disable, modify deleted field, auto flush cache

@param  mixed $where
@return \Wslim\Common\ErrorInfo
disable modify deleted field auto flush cache