<?php
 
class Item extends DataMapper
{
    function __construct($id = NULL)
    {
        parent::__construct($id);        
    }
 
    function search($search_terms)
    {
        $this->distinct()
             ->where('is_active', TRUE)
             ->group_start();
 
        foreach (preg_split('/\s+/', $search_terms) as $search_term) {
            $this->or_like('name', $search_term)
                 ->or_like('description', $search_term);
        }
 
        $this->group_end();
 
        return $this;
    }
}

?>