src/Model/Media/Attachment.php
public static function search($query, &$results = array()) {

        $attachments = static::getInstance();

        if (!empty($query)):
            $words = explode(' ', $query);
            foreach ($words as $word) {
                $_results =
                    $attachments->setListLookUpConditions("attachment_name", $word, 'OR')
                        ->setListLookUpConditions("attachment_title", $word, 'OR')
                        ->setListLookUpConditions("attachment_description", $word, 'OR')
                        ->setListLookUpConditions("attachment_tags", $word, 'OR');
            }

            $_results = $attachments
                ->setListLookUpConditions("attachment_owner", array($attachments->user->get("user_name_id")),"AND",true)
                ->setListOrderBy("o.object_created_on", "DESC")
                ->getObjectsList("attachment");
            $rows = $_results->fetchAll();

            $browsable = array("image/jpg", "image/jpeg", "image/png", "image/gif");
            //Include the members section
            $documents = array(
                "filterid" => "attachments",
                "title" => "Documents",
                "results" => array()
            );
            //Loop through fetched attachments;
            //@TODO might be a better way of doing this, but just trying
            foreach ($rows as $attachment) {
                $document = array(
                    "title" => $attachment['attachment_title'], //required
                    "description" => "", //required
                    "type" => $attachment['object_type'],
                    "object_uri" => $attachment['object_uri']
                );
                if (in_array($attachment['attachment_type'], $browsable)):
                    $document['icon'] = "/system/object/{$attachment['object_uri']}/resize/170/170";
                    $document['link'] = "/system/media/photo/view/{$attachment['object_uri']}";
                else:
                    $document['media_uri'] = $attachment['object_uri'];
                    $document['link'] = "/system/object/{$attachment['object_uri']}";
                endif;

                $documents["results"][] = $document;
            }
            //Add the members section to the result array, only if they have items;
            if (!empty($documents["results"]))
                $results[] = $documents;

        endif;

        return true;
    }
public static function search($query, &$results = array()) {

        $attachments = static::getInstance();

        if (!empty($query)):
            $words = explode(' ', $query);
            foreach ($words as $word) {
                $_results =
                    $attachments->setListLookUpConditions("attachment_name", $word, 'OR')
                        ->setListLookUpConditions("attachment_title", $word, 'OR')
                        ->setListLookUpConditions("attachment_description", $word, 'OR')
                        ->setListLookUpConditions("attachment_tags", $word, 'OR');
            }

            $_results = $attachments
                ->setListLookUpConditions("attachment_owner", array($attachments->user->get("user_name_id")),"AND",true)
                ->setListOrderBy("o.object_created_on", "DESC")
                ->getObjectsList("attachment");
            $rows = $_results->fetchAll();

            $browsable = array("image/jpg", "image/jpeg", "image/png", "image/gif");
            //Include the members section
            $documents = array(
                "filterid" => "attachments",
                "title" => "Documents",
                "results" => array()
            );
            //Loop through fetched attachments;
            //@TODO might be a better way of doing this, but just trying
            foreach ($rows as $attachment) {
                $document = array(
                    "title" => $attachment['attachment_title'], //required
                    "description" => "", //required
                    "type" => $attachment['object_type'],
                    "object_uri" => $attachment['object_uri']
                );
                if (in_array($attachment['attachment_type'], $browsable)):
                    $document['icon'] = "/system/object/{$attachment['object_uri']}/resize/170/170";
                    $document['link'] = "/system/media/photo/view/{$attachment['object_uri']}";
                else:
                    $document['media_uri'] = $attachment['object_uri'];
                    $document['link'] = "/system/object/{$attachment['object_uri']}";
                endif;

                $documents["results"][] = $document;
            }
            //Add the members section to the result array, only if they have items;
            if (!empty($documents["results"]))
                $results[] = $documents;

        endif;

        return true;
    }
Searches the database for attachments

@param type $query
@param type $results