The information I have concerning the Oracle database O need to connect to using PHP through EasyPHP is the following: user, password, host, port, service. I'm new to ODBC. I tried to use the function odbc_connect, but I keep getting errors simply because I don't know how to make a DSN.
I tried using this:
$dns_db="DRIVER={DataDirect 32-BIT SequeLink 5.4};HOST=localhost; PORT=2399;ServerDataSource=maDB;"
But I don't know what {DataDirect 32-BIT SequeLink 5.4} means, and it seems like I need to know the database name so I can put it in the ServerDataSource.
How do I make this DSN thing?
That should be the driver name as it shows up in the ODBC manager. In my computer I have Microsoft ODBC for Oracle and Oracle in instantclient_11_2 to choose from:
Try to use a driver provided by Oracle; the Microsoft one lacks many basic features.
But I'd recommend you to create a system ODBC so you can assign a name of your choice and simply refer to it by such name. Additionally, that allows to configure additional options with the driver's GUI:
Last but not least, my final advice is to dump ODBC completely and use the OCI extension. Coding a PHP app with ODBC is frustrating.
Related
I have php program that requires MS Access, so I had to use odbc. Locally, using DSN it was working fine:
$db = new PDO("odbc:MyDSN");
I also have no problem when I put the php and odbc at the server and access it remotely:
$db = new PDO("odbc:DRIVER=MDBTools; DBQ=Data.mdb;");
But I can't afford to use it for some reason. I want to put php on the server together with the database but I want to place odbc (or the odbc driver) on the client, something like this:
$db = new PDO("odbc:{127.0.0.1\foo\bar\odbc.ini}; DBQ=Data.mdb;");
I can't seems to work with it for a while. I'm using Ubuntu 64bit as server, and Windows 7 as client
UPDATE 1: I found a way to do it, but it needs to modify the PHP itself (Classes,structure,etc.) I hope someone can help me to get alternative solutions
UPDATE 2: Another solution, but requires third party software.
But I can't afford to use it for some reason. I want to put php on the
server together with the database but I want to place odbc (or the
odbc driver) on the client, something like this:
The driver must be loaded by PHP, which is the "client" in this scenario. Means, you'll have to find an appropriate MSAccess ODBC driver for Ubuntu.
Check this SO thread:
ODBC connection to MS-Access on Ubuntu
How to connect to access data base from php 5.3.4 without using odbc connection?
The literal answer to your question, connecting to Access using something other than ODBC is to use OLEDB. See PHP-OLEDB.
If your problem is that you're running PHP on a platform that doesn't have JET ODBC drivers (i.e., not Windows) then you should probably consider using SQLite or more Linux-friendly embedded databases.
If you're dead-set on accessing a JET database from Linux, then take a look at mdbtools.
I'm looking for some tips on how to export a mysql database into a .mdb file that is readable by Microsoft Access 2007+ (and editable too!). It needs to be a script that can run on a Linux server (maybe using PHP?).
I can't seem to find out anything anywhere. Any ideas?
Cheers!
Thanks for your tips :)
I have since found out we're already using this product elsewhere:
http://dbconvert.com/convert-access-to-mysql-pro.php?DB=1
It's running under Wine on our server, although I don't think it supports the latest versions of Access.
Install the ODBC driver from MySQL.
Create the ODBC system DSN entry.
On Access, execute a query like this:
SELECT * INTO AccessTable
FROM [ODBC;DATABASE=Database_Name;DSN=DSN_Name;OPTION=2059;PWD=MySQL_Password;PORT=0;UID=MySQL_User].MySQLTable
(Replace accordingly: AccessTable, MySQLTable, Database_Name, DSN_Name, MySQL_Password, MySQL_User)
You could create a a CSV file from MySql and then import that into Access. You can use OLEDB or ODBC connection to access and should be able to do the inserts that way.
Are you also trying to create the mdb file on the fly? I'm assuming that you have one built already and just want to export the data from mysql and import into access.
I have not tried this.
The unixODBC Project goals are to
develop and promote unixODBC to be the
definitive standard for ODBC on non MS
Windows platforms. This is to include
GUI support for both KDE and GNOME.
-- http://www.unixodbc.org/
We need to access a Teradata database via php application We don't have odbc (unixodbc etc) on the server.
How might one go about connecting to a teradata database quickly.
Keep in mind - this app needs to be as portable as possible.
Teradata provides an ODBC driver. Once installed, it can be accessed via the unixODBC driver manager, assuming your php was built with "--with-unixODBC=shared,/usr".
PHP can then connect to a Teradata database with odbc_connect($dsn, $user, $passwd);
The Teradata ODBC driver installation includes a sample odbc.ini file, which you can cp to .odbc.ini in your home directory, then modify to contain the DSN for your Teradata database.
Set the environment variable ODBCINI to the location of your odbc.ini file to use (/home/johndoe/.odbc.ini is common).
Be warned: the Teradata ODBC driver provides a rich set of DML statements, but very few are exposed through the unixODBC driver manager. The collection of PHP's odbc_xxxx() functions is a crippled subset of what the Teradata ODBC driver offers.
This method would help you if u are ok with the memory implications and this would help you if you have teradata command line utility BTEQ installed on your machine.
But better method would be by ODBC as it gives you the flexibility. In the above method of command line execution of SQL scripts by system() function, you can use an easier language like R for parsing the output resultset.
I think you may also do it by jdbc connection. You can also download any of these odbc/jdbc drivers from this link.
You may be out of luck.
PDO doesn't have a native driver
ADODb doesn't have a native driver
judging from what I find from a cursory web search, I'd say it is not possible to connect from PHP to a Teradata database without ODBC.
How do I connect to a remote Oracle database instance from PHP?
I need to query (read only) the remote Oracle database for some information; do I need to have an Oracle Instant Client installed?
Is the OCI extension for PHP enough?
From PHP Manual
You will need the Oracle client libraries to use this extension.
The most convenient way to install all the required files is to use Oracle Instant Client, which is available from Oracle's site
The best manual for using PHP with Oracle is Underground PHP Oracle Manual. Periodically updated. For example last update describe new cool OCI (Oracle Call Interface) features. I found it by accident and since then has never regretted. Start from that good manual.
there are a couple of steps you need to go through to make this work.
First, you need to install the oracle driver for whatever OS you have. Then, create a DSN for odbc to use to connect the php function call to the oracle database. On windows, you can find this on the Control Panel -> ODBC Sources
Once you have done this, restart the DB, the web server and then you should be able to test it all with this:
odbc_connect($dsn,$user,$pass);
If you have linux, the same steps are needed but I'm not sure how you create a DSN in unix.
I saw this in the "Notes" section of the PHP documentation:
If you're using PHP with Oracle Instant Client, you can use easy connect naming method (...)
So I think it's rather clear that you can connect to an Oracle DB without the Oracle Instant Client, using only the PHP Oracle extension.
If you're attempting to connect to oracle on ubuntu with PHP, the following links have been more than helpful:
A) http://pecl.php.net/bugs/bug.php?id=9253
That's the real-workhorse one - it gives you just about all the data you need.
B) http://fabrizioballiano.net/2008/01/26/how-to-install-php-pdo_oci-on-ubuntu-gutsy/
This is also helpful for details of things that need to be installed for oracle to work with ubuntu.
If you're using it with PHP, you'll need to make sure that the TNS_ADMIN and ORACLE_HOME environment variables are available for apache's user - there's a file named 'envvars' in the apache2 directory where you can set these. (For my own ease of use, I have the two point to the same directory.)