• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to search between encoded data in mysql database?

#1
[eluser]afshin[/eluser]
I have encoded some data using codeigniter's encryption method and stored them in mysql database. There is no problem retrieving them, but when I want to search between them, it appears to be nonsense. How can I search between encoded data in mysql and codeigniter?

This is my encoding function:

Code:
function _encode($options = array()){

    $key = 'Q7tBBb1iECkl5Kk1U3mVPur1J863KGz4';

    $encoded = $this->encrypt->encode($options['code'], $key);

    return $encoded;
}


This is what I use as a search method in my Model:


Code:
function search()
{
    //Pagination config
    $search_by = $this->session->userdata('search_by');
    $search_term = $this->_encode($this->session->userdata('search_term'));

    $config['base_url'] = base_url() . 'acp/cds/search_result/page/';
    $config['total_rows'] = $this->db->like($search_by, $search_term)->get('cards')->num_rows();
    $config['per_page'] = 15;
    $config['num_links'] = 4;
    $config['uri_segment'] = 5;
    $this->pagination->initialize($config);

    $page_num = $this->uri->segment(5, 1);
    $offset = ($page_num - 1) * $config['per_page'];
    $this->db->order_by('card_Id', 'ASC');        
    $this->db->like($search_by, $search_term);
    $query = $this->db->get('cards', $config['per_page'], $offset);

    return $query->result();        
}


Messages In This Thread
How to search between encoded data in mysql database? - by El Forum - 07-06-2012, 10:26 AM
How to search between encoded data in mysql database? - by El Forum - 07-06-2012, 10:48 AM
How to search between encoded data in mysql database? - by El Forum - 07-06-2012, 10:53 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.