Assalamualaykum :)
i have trouble when i want to generate a query in codeigniter, here is the code :
class Pengadilan_negeri extends CI_Controller {
private function get_database_configuration($database_name) {
$configuration = array(
'hostname' => "DREAMBENDER\PENGADILANNEGERI",
'username' => "sa",
'password' => "12111993",
'dbdriver' => "mssql"
);
$database_configuration = NULL;
if ($database_name == "pidana") {
$database_configuration = $configuration + array('database' => "dataPidana");
} else if ($database_name == "perdata") {
$database_configuration = $configuration + array('database' => "dataPerdata");
}
return $database_configuration;
}
public function biasa() {
$DB1 = $this->load->database($this->get_database_configuration("pidana"), TRUE);
$DB2 = $this->load->database($this->get_database_configuration("perdata"), TRUE);
$DB1->query("SELECT * FROM dbo.DATA_REGISTER");
foreach ($DB1->result() as $row) {
print_r($row);
}
}
}
and the're some error output like this :
Fatal error: Call to undefined method CI_DB_mssql_driver::result() in E:\xampp\htdocs\pengadilan_negeri\application\controllers\register_perkara\perkara_pidana.php on line 33
what should i do to make this code running without errors ?
$this->load->database('pidana', TRUE);@Toast: there is the code in line 33 :foreach ($DB1->result() as $row) {if we puth both of them in the config file, and we use$this->database->query($query);there will be ambigous query, because the system won't know the query that we want to execute is a query to "pidana database" or "perdata database". but (alhamdulillah) i have solved this problem 10 menutes ago. btw, thanks for your answer