Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] odbc connection string to native CI database
#1

[eluser]luke holder[/eluser]
Hi,

as you can see i'm new. Be nice.


I have successfully connected to my odbc database, and listed the tables with this code
Code:
$connection = odbc_connect("Driver={Timberline Data};DBQ=T:\Gold\DORIC PJ PR;CODEPAGE=1252;DictionaryMode=0;StandardMode=1;MaxColSupport=1500;ShortenNames=0;DatabaseType=1;", "HOLDLUK", "HOLDLUK","SQL_CUR_USE_ODBC");

        $result = odbc_tables($connection);
        
           $tables = array();
          
           while (odbc_fetch_row($result)){
             if(odbc_result($result,"TABLE_TYPE")=="TABLE")
               echo"<br>".odbc_result($result,"TABLE_NAME");
        
           }

This is in a controller, and obviously i want to use the native database object in CI.

Could someone explain how i would put the connection string into the CI database array below...

Code:
$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "";
$db['default']['username'] = "";
$db['default']['password'] = "";
$db['default']['database'] = "";
$db['default']['dbdriver'] = "odbc";
$db['default']['dbprefix'] = "";
$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";

I need to have the parameters or the odbc connection will fail... where would they go in the above?

This is a proprietary sage timberline odbc driver.
#2

[eluser]luke holder[/eluser]
I have attempted the following, but obviously doesn't work. My issues seems to be "where to i specify my odbc driver?
Code:
class Mainx extends Model {

    function Mainx()
    {
        parent::Model();
        
        $dsn = 'odbc://HOLDLUK:HOLDLUK@hostname/?CODEPAGE=1252&DictionaryMode=0&StandardMode=1&MaxColSupport=1500&ShortenNames=0&DatabaseType=1';
        //$connection = odbc_connect("Driver={Timberline Data};DBQ=T:\Gold\DORIC PJ PR;CODEPAGE=1252;DictionaryMode=0;StandardMode=1;MaxColSupport=1500;ShortenNames=0;DatabaseType=1;", "HOLDLUK", "HOLDLUK","SQL_CUR_USE_ODBC");
        
        $this->load->database($dsn);
    }
}
#3

[eluser]luke holder[/eluser]
i'm surprised no-one can help.

what are the chances this may get looked at once its off the front page of the forum?
#4

[eluser]jedd[/eluser]
Hi lukemh,

Almost none.

It's not that surprising - because you're using a proprietary sage timberline ODBC driver. (I haven't even heard of sage or timberline.) Most people around here use MySQL, and we have the occasional postgres, MSSQL, and Oracle user .. and even more occasionally, someone with an ODBC problem. Because most forum users only stick around long enough to solve their own problem .. you're consequently looking at a very tiny demographic.

I'm assuming you've searched through the forums? I found only one vaguely potentially useful page: [url="http://ellislab.com/forums/viewthread/93160/"]http://ellislab.com/forums/viewthread/93160/[/url] Most of the other vaguely related pages were people asking questions that, regrettably, never got answered.

It's probably unlikely, but I have to ask JIC you haven't pursued this avenue - can the proprietors of this dodgy driver provide any assistance here?

Short of modifying the database CI library (a very bad idea - messy to upgrade) or following the wiki article on effectively extending it (probably the neatest approach) and doing some dodgy hard-coded db connections in there, to get you up and running in the short term at least, I don't think you're going to find (m)any people that have specific experience with this type of problem.
#5

[eluser]luke holder[/eluser]
this thread fixed my problem

THANKS a MILLION

http://ellislab.com/forums/viewthread/93160/




Theme © iAndrew 2016 - Forum software by © MyBB