比如我要连接到trademark
数据库中,则在需要跨库的model中这样写:
<?php
class trademark extends CI_Model {
protected $ln = NULL;
function __construct() {
parent::__construct();
$this->ln = $this->load->database('trademark',TRUE);
}
public function retrieve($criteria) {
$val = $criteria['txt'];
$field = $criteria['field'];
$this->ln->select('*')->from('trademark_information_retrieval');
$this->ln->like($field, $val, 'both');
$result = $this->ln->get()->result();
return $result;
}
}
trademark
配置组放到database.php
文件中,同里面的default
组同样设置即可。