Welcome Guest, Not a member yet? Register   Sign In
Problem using two different database
#1

Hello, people of the forum.
All right?

I'm working with two databases, MySQL as primary and Progress as secondary bank via ODBC ...
The following is the code for the connections:

database.php

PHP Code:
$active_group 'default';
$query_builder TRUE;
$active_record TRUE;

$db['default'] = array(
    
'dsn'    => '',
    
'hostname' => 'Xxxx',
    
'username' => 'Xxxx',
    
'password' => 'Xxxx!',
    
'database' => 'Xxxx',
    
'dbdriver' => 'mysqli',
    
'dbprefix' => '',
    
'pconnect' => FALSE,
    
'db_debug' => (ENVIRONMENT !== 'production'),
    
'cache_on' => FALSE,
    
'cachedir' => '',
    
'char_set' => 'utf8',
    
'dbcollat' => 'utf8_general_ci',
    
'swap_pre' => '',
    
'encrypt' => FALSE,
    
'compress' => FALSE,
    
'stricton' => FALSE,
    
'failover' => array(),
    
'save_queries' => TRUE
);


$db['Zzzzzzzzz'] = array(
    
'dsn'       => '',
    
'hostname' => 'Zzzz',
    
'username' => 'Zzzz',
    
'password' => 'Zzzz',
    
'database' => 'Zzzz',
    
'dbdriver' => 'odbc',
    
'dbprefix' => '',
    
'pconnect' => FALSE,
    
'db_debug' => (ENVIRONMENT !== 'production'),
    
'cache_on' => FALSE,
    
'cachedir' => '',
    
'char_set' => 'utf8',
    
'dbcollat' => 'utf8_general_ci',
    
'swap_pre' => '',
    
'encrypt' => FALSE,
    
'compress' => FALSE,
    
'stricton' => FALSE,
    
'failover' => array(),
    
'save_queries' => TRUE
); 


The default database is working normally, but when I try to access the database via ODBC with activerecord the following error:
Code:
Fatal error: Call to undefined method CI_DB_odbc_driver::get() in C:\xampp\htdocs\novo\application\modules\test\models\Md_test.php on line 15

md_test .php
PHP Code:
class Md_test extends CI_Model {

    function 
__construct(){
        
parent::__construct();
        
$this->test$this->load->database('Zzzzzzzzz'TRUE);
    }

 
   
    function buscaPedidos
($dt)
    {
        return 
$this->test->get('Zzzzz'); // line 15
    
}
 
   


Can anybody help me?
Reply
#2

The query builder cannot be used with the ODBC driver. See https://forum.codeigniter.com/thread-65803.html
Reply
#3

I was able to mount a query and return an array, but it does not show me the name of the columns (key)...

PHP Code:
$data['test'] = $this->md_test->buscaPedidoAtual($dt);
$row $data['test']->result_array();

echo 
'<pre>';
var_dump($row);
echo 
'</pre>'

Result:
Code:
array(49) {
 ["100"]=>
 string(3) "100"
 ["1"]=>
 string(1) "1"
 ["0131826"]=>
 string(7) "0131826"
 ...
 ...
...
...
Reply




Theme © iAndrew 2016 - Forum software by © MyBB