Object::suggestContent PHP Method

suggestContent() public method

public suggestContent ( $keyword, $type = '', $limit = 20 )
    public function suggestContent($keyword, $type = '', $limit = 20)
    {
        if ($type == '') {
            $objects = $this->findAll(array('condition' => 'object_name LIKE :keyword', 'order' => 'object_id DESC', 'limit' => $limit, 'params' => array(':keyword' => '%' . strtr($keyword, array('%' => '\\%', '_' => '\\_', '\\' => '\\\\')) . '%')));
        } else {
            $objects = $this->findAll(array('condition' => 'object_type = :t and object_name LIKE :keyword', 'order' => 'object_name DESC', 'limit' => $limit, 'params' => array(':t' => trim(strtolower($type)), ':keyword' => '%' . strtr($keyword, array('%' => '\\%', '_' => '\\_', '\\' => '\\\\')) . '%')));
        }
        $names = array();
        foreach ($objects as $object) {
            $names[] = str_replace(";", "", $object->object_name) . "|" . $object->object_id;
        }
        return $names;
    }