CodeIgniter Forums
odbc connection to a remote system - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: odbc connection to a remote system (/showthread.php?tid=14179)

Pages: 1 2


odbc connection to a remote system - El Forum - 12-22-2008

[eluser]Henry Weismann[/eluser]
Hmmm it says this in the user guide:

# port - The database port number. Currently only used with the Postgres driver. To use this value you have to add a line to the database config array.

Check the ODBC driver and make sure port is being used.


odbc connection to a remote system - El Forum - 12-22-2008

[eluser]Waiel[/eluser]
well i tried to add the port in the host name but no luck also

looks like i need to check the odbc_connect and figure out how to connect to specific port

thanks Henry for all your help ..


odbc connection to a remote system - El Forum - 12-22-2008

[eluser]Henry Weismann[/eluser]
No problem...

You could also try using the dsn:
Code:
$dsn = 'dbdriver://username:password@hostname/database?char_set=utf8&dbcollat=utf8_general_ci&port=8888';

$this->load->database($dsn,true);

If that doesnt work then you should look at how CI connects and see if it uses the port and also make sure that you are using the right method for odbc and access.


odbc connection to a remote system - El Forum - 12-22-2008

[eluser]Waiel[/eluser]
well i did try it but no luck ...

CI odbc doesn't connect to a port >< so i need figure out something ..

would be great if CI odbc connect through port Smile in 1.7.1 Tongue


odbc connection to a remote system - El Forum - 10-21-2009

[eluser]George Tavas[/eluser]
A few days ago i was trying to connect into MS Access database with no luck.
So I figured out that the ODBC driver has some difficulties connecting into an MS Access db.
So I used the easiest workaround that i probably could think ath the time.

I used odbc_connect() to connect at the mdb driver and then i manually set the established connection as the active record driver property $conn_id.

Example
Code:
//Just make a false connection with db_debug unset or false just to initialize the  
//ODBC_Driver object
        $dsn = 'odbc://127.0.0.1/database?&char_set=utf8&dbcollat=utf8_general_ci&port=8888';
        $access = $this->load->database($dsn, true);
//Then create dsn connection.
        $dsn = "Driver={Microsoft Access Driver (*.mdb)};DefaultDir=C:/path/to/datbdase/folder;Dbq=your_db.mdb";
        
//Establish the connection
        $con = odbc_connect($dsn,"username","password");
//Set connection as the conn_id property in the ODBC_Driver
        $access->conn_id = $con;
//Set db_debug to TRUE to be able see any errors on your queries
        $access->db_debug = true;
        
//You are ready to work with active record
        $res = $access->get("MyTable");
        
        print_r($res->result());