Connecting to Teradata via PHP - 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.

Related

Laravel connect to Azure SQL Data warehouse using PDO

I am using Laravel 5 and want to connect to a Azure Data warehouse using the implemented PDO database connection Laravel provides. I am using the following connection settings.
DB_CONNECTION=sqlsrv
DB_HOST=tcp:srv.url.com,1433
DB_DATABASE=db-name
DB_USERNAME=user
DB_PASSWORD=pass
When I load the page I get a "could not find driver" error.
How is this possible? The drivers are build into Laravel rigth?
Thanks in advance!
You need to install the PDO driver for sqlsrv manually, configure in PHP PDO_SQLSRV extension enabled by adding appropriate DLL file like php_pdo_sqlsrv_53_nts.dll, and which is only compatible with PHP running on Windows. You can refer to http://php.net/manual/en/ref.pdo-sqlsrv.php for more info.
To connect to SQL server in PHP in Unix, you can use ODBC extension and Microsoft's SQL Server ODBC Driver for Linux.

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.

What is diffrence between odbc_connect() and mssql_connect()

In php, to connect to MSSQL server , what is diffrence between odb_connect() and mssql_connect()???
odbc_connect is a generic database connection (you can specify the driver), while mssql_connect is MSSQL specific
Also the manual says that complex queries may fail with odbc drivers.
odbc_connect() requires you have the PHP ODBC extension loaded and UNIXodbc installed and configured on the web server, whereas mssql_connect() only requires that you have the MSSQL extension.
If your looking to connect to a SQL Server via PHP, might I recommend that you use Microsoft's SQLSRV PHP driver. It's much better than the native php_mssql extension and gives you a lot more functionality. Make sure you also install SQL Server native client, or it won't work.

How to use PHP to connect to an Informix database?

First, I would like to introduce the problem.
I have a Informix database that is currently used by 300 staffs (average is around 100,000 records/query) that make this server work slowly. Current architecture is:
Informix DB ⟷ Web Application
Now I want to implement the new system by adding new MySQL server with the following architecture
Informix DB ⟷ MySQL Server ⟷ Web Application
In MySQL Server I would like to copy the database from Informix to MySQL server by using PHP + Cronjob.
The questions are:
Is there has any ODBC / JDBC driver (must be FREE!!) in LINUX for connecting to Informix?
How to use it?
PHP has an extension for connecting to Informix. See the manual pages here: http://php.net/manual/en/book.ifx.php
You can also use the PDO extension with its Informix driver: http://php.net/manual/en/ref.pdo-informix.php
In both cases, you need to ensure that your copy of PHP has been built with those extensions. You can check what extensions are in your copy of PHP by seeing the output of the php_info() function. If it doesn't include the relevant extensions, then you'll need to rebuild your copy of PHP to include them.
The IBM Informix ClientSDK (CSDK) includes both ODBC and JDBC drivers, and can be obtained free of charge. If you want support for the software, there is a charge, of course.
If you go to http://www.informix.com/ (the www is crucial; omit it and you get to the IBM home page), you get directed to http://www.ibm.com/software/data/informix/. The free database editions include CSDK in the download. It is possible to get CSDK standalone, without the server, too. And IBM Informix Connect (I-Connect) is the runtime part of CSDK.
You can connect to Informix from PHP with PDO Informix or PDO IBM modules.

connect to access database from 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.

Categories