Welcome Guest, Not a member yet? Register   Sign In
MeNeedz Search
#35

[eluser]davidbehler[/eluser]
Sorry for the late reply but this should answer your questions:

hugle
The model from the example looks like this:
Code:
<?php
class Search_model extends Model {
    function Search_model()
    {
        // Call the Model constructor
        parent::Model();
    }

    function get_article_list($id_list = array(), $order_by = array())
    {
        $this->db->from('articles');
        if(count($id_list) > 0)
        {
            $this->db->where_in('id', $id_list);
        }
        if(count($order_by) > 0)
        {
            foreach($order_by as $key => $value)
            {
                $this->db->order_by($key, $value);
            }
        }
        $result = $this->db->get();
        if($result->num_rows() > 0)
        {
            $rows = $result->result_array();
            return $rows;
        }
        else
        {
            return array();
        }
    }
}
?>
The articles table I used was taken from some MySQL example I found some time ago. If you want me to I can look for the CREATE statement and post it here, but it's really nothing special about it.
The pagination is all done in the library, have a look a the "scroll" method.

zvir
This is an example config I set up some time back:
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    $config['max_age'] = 20; //in seconds
    $config['db_config'] = array(
        'table' => 'search',
        'id_column' => 'search_id',
        'hash_column' => 'search_hash',
        'name_column' => 'search_name',
        'perform_column' => 'search_date_perform',
        'count_column' => 'search_result_count',
        'where_column' => 'search_where',
        'result_column' => 'search_result',
        'order_column' => 'search_order_by'
    );
    $config['search_config'] = array(
        'test_search' => array(
            'search_id_field' => 'user_id',
            'search_from' => "user",
            'search_join' => array(
                'user_group' => 'user.user_group = user_group.group_id'
            ),
            'search_default_where' => "is_active = 1",
            'search_post_where' => array(
                array(
                        'post_field' => 'username',
                        'db_column' => 'user_name',
                        'operator' => 'MATCH',
                        'mode' => 'IN BOOLEAN MODE'
                    ),
                array(
                        'post_field' => 'min_age',
                        'db_column' => 'age',
                        'operator' => '>'
                    )
            ),
            'search_post_order' => array(
                'db_column_post_field' => 'column_field',
                'order_post_field' => 'order_field'
            )
        ),
        'example_1' => array(
            'search_id_field' => 'id',
            'search_from' => "articles",
            'search_join' => array(),
            'search_default_where' => "",
            'search_post_where' => array(
                array(
                        'post_field' => 'search_term_example_1',
                        'db_column' => 'body',
                        'operator' => 'LIKE'
                    )
            ),
            'search_post_order' => array()
        ),
        'example_2' => array(
            'search_id_field' => 'id',
            'search_from' => "articles",
            'search_join' => array(),
            'search_default_where' => "",
            'search_post_where' => array(
                array(
                        'post_field' => 'min_id',
                        'db_column' => 'id',
                        'operator' => '>'
                    ),
                array(
                        'post_field' => 'max_id',
                        'db_column' => 'id',
                        'operator' => '<'
                    )
            ),
            'search_post_order' => array(
                'db_column_post_field' => 'column_field',
                'order_post_field' => 'order_field'
            )
        )
    );
?&gt;
test_search and example_2 both search in multiple columns. Depending on wether you want to use one post value to search for in multiple columns or multiple post values to search for in one column or whatever else you want to do, you have to adjust the "search_post_where" config value. If you run into any problems with this, feel free to post more info on what you are doing and I'll try to help you setup the config right.

Hope I could help.


Messages In This Thread
MeNeedz Search - by El Forum - 01-30-2009, 06:04 PM
MeNeedz Search - by El Forum - 01-30-2009, 09:29 PM
MeNeedz Search - by El Forum - 01-30-2009, 09:33 PM
MeNeedz Search - by El Forum - 01-31-2009, 03:35 AM
MeNeedz Search - by El Forum - 02-01-2009, 11:40 AM
MeNeedz Search - by El Forum - 02-01-2009, 12:12 PM
MeNeedz Search - by El Forum - 02-04-2009, 08:53 AM
MeNeedz Search - by El Forum - 02-04-2009, 09:15 AM
MeNeedz Search - by El Forum - 02-04-2009, 09:35 AM
MeNeedz Search - by El Forum - 02-04-2009, 10:00 AM
MeNeedz Search - by El Forum - 02-21-2009, 09:48 AM
MeNeedz Search - by El Forum - 02-21-2009, 11:40 AM
MeNeedz Search - by El Forum - 02-21-2009, 02:27 PM
MeNeedz Search - by El Forum - 02-22-2009, 02:36 PM
MeNeedz Search - by El Forum - 02-22-2009, 04:22 PM
MeNeedz Search - by El Forum - 02-23-2009, 04:09 PM
MeNeedz Search - by El Forum - 02-23-2009, 05:13 PM
MeNeedz Search - by El Forum - 02-23-2009, 05:52 PM
MeNeedz Search - by El Forum - 02-23-2009, 06:02 PM
MeNeedz Search - by El Forum - 02-24-2009, 06:04 AM
MeNeedz Search - by El Forum - 02-24-2009, 12:08 PM
MeNeedz Search - by El Forum - 03-16-2009, 02:05 PM
MeNeedz Search - by El Forum - 03-16-2009, 03:20 PM
MeNeedz Search - by El Forum - 04-23-2009, 06:21 AM
MeNeedz Search - by El Forum - 04-23-2009, 08:22 AM
MeNeedz Search - by El Forum - 04-23-2009, 07:56 PM
MeNeedz Search - by El Forum - 04-24-2009, 10:47 AM
MeNeedz Search - by El Forum - 05-19-2009, 03:58 AM
MeNeedz Search - by El Forum - 05-19-2009, 07:35 AM
MeNeedz Search - by El Forum - 05-26-2009, 08:55 AM
MeNeedz Search - by El Forum - 05-26-2009, 10:05 AM
MeNeedz Search - by El Forum - 09-07-2009, 07:35 AM
MeNeedz Search - by El Forum - 09-07-2009, 09:17 AM
MeNeedz Search - by El Forum - 09-29-2010, 05:59 AM
MeNeedz Search - by El Forum - 09-30-2010, 03:58 AM
MeNeedz Search - by El Forum - 09-30-2010, 04:41 AM
MeNeedz Search - by El Forum - 09-30-2010, 05:07 AM
MeNeedz Search - by El Forum - 09-30-2010, 05:08 AM
MeNeedz Search - by El Forum - 11-29-2010, 03:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB