• 5th May 2010 - By admin

    I know its been a bit of a whole since my last update but have a bit of useful info here:

     function beforeFind(&$queryData)
    	{
    	    $conditions = $queryData['conditions'];
    
    	    if (!is_array($conditions)) {
    	        if (!$conditions) {
    	            $conditions = array();
    	        } else {
    	            $conditions = array($conditions);
    	        }
    	    }
    
    	    if (!isset($conditions['active']) && !isset($conditions[$this->alias . '.active'])) {
    	        $conditions[$this->alias . '.active'] = 1;
    	    }
    
    	    $queryData['conditions'] = $conditions;
    	    return true;
    	}

    Put this in the model that you have an ‘active’ field in and it will save you having to add a condition into each find statement to check whether that record is flagged as active / inactive!

    Share with your friends and help out this site:
    • Digg
    • del.icio.us
    • Facebook
    • Google Bookmarks
    • E-mail this story to a friend!
    • LinkedIn
    • Live
    • Reddit
    • StumbleUpon
    • Twitter
    • Yahoo! Bookmarks

Ad