In fact, this is not a difficult thing, because just started CI, so it is also a cost of some twists and turns. Fortunately there are manuals.
Locate the database configuration file and add the connection information for a new library. $config [XX].
Inside the controller,
a) $this->xx = $this->load->database (' xx ', true) tip:xx represents the key name of the array of database information you configured, followed by the recommended setting to TRUE, Return connection ID and enable Actionrecord class, respectively
b) Then in the controller you can use $this->xx->query () to query the data of your other library. And you have another library that does not need to build the Modle file
Copy CodeThe code is as follows:
function __construct ()
{
Parent::__construct ();
$this->xx = $this->load->database (' xx ', TRUE);
$this->load->model (' Default Library table name ');
}
Function index ()
{
Now you can use $this->xx->query () to execute the SQL of XX library.
$this->xx->query ($sql);
}
?>
http://www.bkjia.com/PHPjc/325681.html www.bkjia.com true http://www.bkjia.com/PHPjc/325681.html techarticle In fact, this is not a difficult thing, because just started CI, so it is also a cost of some twists and turns. Fortunately there are manuals. Locate the database configuration file and add the connection information for a new library. $config ...