Jump to content

gun41exe

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

gun41exe's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi ..., I'm trying to implement multiple database in CI. My code Is here: //database.php $active_group = "default"; $active_record = TRUE; $db['default']['hostname'] = "localhost"; $db['default']['username'] = "root"; $db['default']['password'] = "root"; $db['default']['database'] = "ravelex"; $db['default']['dbdriver'] = "mysql"; $db['default']['dbprefix'] = "rvx_"; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = TRUE; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = ""; $db['default']['char_set'] = "utf8"; $db['default']['dbcollat'] = "utf8_general_ci"; $db['smf']['hostname'] = "localhost"; $db['smf']['username'] = "root"; $db['smf']['password'] = "root"; $db['smf']['database'] = "smf"; $db['smf']['dbdriver'] = "mysql"; $db['smf']['dbprefix'] = "smf_"; $db['smf']['pconnect'] = TRUE; $db['smf']['db_debug'] = TRUE; $db['smf']['cache_on'] = FALSE; $db['smf']['cachedir'] = ""; $db['smf']['char_set'] = "utf8"; $db['smf']['dbcollat'] = "utf8_general_ci"; The model is //user_model.php class user_model extends Model { private $ravelex_db; function user_model() { parent::Model(); $this->ravelex_db = $this->load->database('default', TRUE); } function find_all() { print_r($this->ravelex_db); $q = $this->ravelex_db->get('users'); return $q->result(); } } //smf_user_model.php class smf_user_model extends Model { private $smf_db; function smf_user_model() { parent::Model(); $this->smf_db = $this->load->database('smf', TRUE); } function find_all() { $q = $this->smf_db->get('members'); return $q->result(); } } Controller tester class mutipledb extends Controller { function mutipledb() { parent::Controller(); $this->load->database(); $this->load->model('user_model'); $this->load->model('smf_user_model'); } function index() { print_r($this->user_model->find_all()); print_r($this->smf_user_model->find_all()); } } There are some error, The first database uses the second database name. But it still use it's prefix. The error is A Database Error Occurred Error Number: 1146 Table 'smf.rvx_users' doesn't exist SELECT * FROM (`rvx_users`) But if I just load one model, It works. Why this could be happened ? Help me please .....
  2. upss .., sory. It should be 3. thanks for correction.
  3. Hi ..., Im trying to implement pagination using multiple searching criteria. Supposed I Have student table. I also use pagination when the list of student displayed. The pagination link is. `site_url . '/student/page/';` so I use `$config['uri_segment'] = 1`; so the pagination link will be <a href="http://mysite/index.php/student/page/0">1</a> <a href="http://mysite/index.php/student/page/1">2</a> and son. After that I wanna search student data using 3 searching criteria implemented using textfield. id name address. user can search by id or name or address or combination of the three criteria. the url become http://mysite/index.php/student/page/0 href=http://mysite/index.php/student/page/1 and son. but I use get method for searching. and while trying to search using the search criteria field the url become href="http://mysite/index.php/student/page/1?id=1&name=a&address=b the problem occurred when I try create pagination based on criteria. because the pagination link have contain query string i don't know how to create become href="http://mysite/index.php/student/page/0?id=1&name=a&address=b href="http://mysite/index.php/student/page/1?id=1&name=a&address=b or do you have a best practice to solve this problem ?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.