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

[eluser]davidbehler[/eluser]
There is no such function yet, but you could easily add a function that stores the number of times a keyword has been searched. You would propably have to call that function in the perform method around line 100.

Code:
$this->CI->input->post($post_field); //This is should be the keyword
#32

[eluser]hugle[/eluser]
Hello,

I now came to project I really need to use a search.

I came to your only search available again. Maybe you have updated smth?

btw, I see :$this->load->model('Search_model'); - but there is no model in archive...

Thanks for help David!

Jaroslav
#33

[eluser]hugle[/eluser]
btw David,

I've looked deeper threw your search library. It seems you've also implemented pagination there?

As I understood, you are using your model for working with examples?
can you post search_model.php and other MySQL tables involved in this search?

I really want to use your search for start, and wanna add such functionalies, as 'how many times keyword was met in article' if that's possible..

Thank you Smile
#34

[eluser]zvir[/eluser]
HI,

i'm using your library and it works great, but i have one question, is it posible to search through multiple columns or just one?? i tried couple of things but i just can't make it work on multiple columns.

please help

thanks!
#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.
#36

[eluser]zvir[/eluser]
yes, i understand this, but as i can see this kind of search creates this kind of sql:
Code:
select * from "search_from" where "db_column" "operator" "post_field" AND "db_column" "operator" "post_field"

what i need is:

Code:
select * from "search_from" where "db_column" "operator" "post_field" OR "db_column" "operator" "post_field"

so it gets results from either of those two columns. or maybe i'm wrong...

hope you understand what i'm trying to say.

thanks
#37

[eluser]davidbehler[/eluser]
The library does not support the OR operator for where constraints right now. You can either add it yourself or wait till I found the time to do so...which might take a while Wink
#38

[eluser]zvir[/eluser]
ok, i'll try it myself...

thanks for reply!
#39

[eluser]zvir[/eluser]
hi, i have one more question. when i enter 'search_default_where' value it creates query like this:

Code:
SELECT search_id_field FROM (search_from) WHERE search_default_where AND db_column[0] LIKE '%test%'
OR  db_column[1] LIKE '%test%' OR  db_column[2]  LIKE '%test%'

and this kind of query ignores 'search_default_where' value. the query works only if i put db_columns in () like this:

Code:
SELECT search_id_field FROM (search_from) WHERE search_default_where AND (db_column[0] LIKE '%test%'
OR  db_column[1] LIKE '%test%' OR  db_column[2]  LIKE '%test%')

so now i'm confused and can't get it to work as i want...

please help...

edit: solved, i edited it to support OR and parentheses. thanks anyway for this great library!




Theme © iAndrew 2016 - Forum software by © MyBB