connect to access database from php - php

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.

Related

Create a DSN for the function odbc_connect for Oracle

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.

Connecting to Teradata via PHP

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.

Pervasive & Linux

I'm interested in quering a Pervasive DB server running on a Windows platform from Linux.
Would anyone happen to know if this is possible, what's required and what resources there are for me to read up on it?
Thanks!
What version of Pervasive are you using? All versions since v8 (including v9 and v10) support a Linux client which is included with the Pervasive.SQL server engine. V9 and V10 clients are also available for download from the Pervasive website (http://www.pervasivedb.com/Database/Products/PSQLv10/Pages/PSQLOverview.aspx). Once you've got a client installed on the Linux machine, you can create an ODBC DSN or use the Btrieve API to access the data.
Most database have at least a command line client to connect to database. check your brand of database to see if you have such tools. For example, Mysql has mysql command line client for making query to MySql database. Otherwise, another way is you might want to try setting up ODBC with Perl.

Using sqlsrv_connect on Platforms other than Windows

I've inherited some code that uses the sqlsrv_connect method to instantiate a connection to a SQL Server database. My personal development machine is an OS X box that I'm running apache an PHP on. I have an instance of SQL Server running in a virtual machine.
When I attempt to connect to the database, I get the following error.
Fatal error: Call to undefined function sqlsrv_connect() in ...
It appears that sqlsrv_connect is not part of standard PHP, and is part of a driver that ships with SQL Server 2005. (please correct me if I'm wrong here)
Is there a way to use this function on Non-Windows platforms? I realize I could install/build an Apache/PHP instance on my Windows machine, but if there's a way to get this function working on OS X (or other *nixes) I'd prefer it.
Is not possible. The SQL Native Driver for PHP is Windows only product:
The SQL Server Driver for PHP relies
on the Microsoft SQL Server 2005 ODBC
Driver to handle the low-level
communication with SQL Server. As a
result, the SQL Server Driver for PHP
is only supported on Windows.
You can look here for a tutorial on how to install the extension. (Via Google)
I'm not too famillar with the extension, but that source should be able to help you out.
(Updated Link to Better Source, still via Google)
The SQL Server Driver for PHP (from MS) is available only on Windows. Unless you want some specific features offered by this driver/ API, you can use the PHP ODBC module along with UnixODBC/ iODBC driver, or FreeTDS (ODBC or db-lib)

Connecting to Oracle using PHP

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.)

Categories