Interested in using PHP on various platforms including Linux? Looking into integrating your website or application scripted in PHP with various data sources? You may want to check out our Connect for ODBC drivers.
The common problem faced by PHP developers is how to make a scalable and fast connection to various data sources. In today’s world, everyone uses the magic words: real-time integration. Using a standard-based third party driver can simplify the whole process, saving you money and developer time. If you choose a driver that is easy to white label, your customer doesn’t even need to know.
An Example: Connecting SQL Server on Linux via ODBC
Let’s say you are looking for a 64bit ODBC driver for SQL Server on Linux for a custom made application written in PHP. You need an easy solution to improve connectivity between the application and SQL server. Usually this means rebuilding the PHP code to establish the connection, but you already spent significant man-hours on the project, and who knows how many customers actually need the connection?
Well, an easy answer is that DataDirect Connect for ODBC provides connectivity from UNIX/Linux platforms to the Microsoft SQL Server. Since our drivers offer wire protocol solutions, you don’t need database vendor client libraries. So in short, not only is this a scalable solution, it will also be very fast one (I do think you have heard about the bulk load before…).
Just Imagine the Possibilities…
PHP is a robust scripting language useful for everything from small projects to enterprise application development. After all, the PHP motto is: PHP powers everything from your blog to the most popular websites in the world. By using DataDirect Connect for ODBC drivers, you can easily write portable PHP code for all major operating systems and platforms. DataDirect Connect for ODBC offers both performance and scalability benefits through the use of its unique wire protocol architecture. Wire protocol architecture also removes the need for vendor client libraries, which results in easier deployment and maintenance of your applications.
Oh, last but not least, DataDirect Connect for ODBC drivers are the most widely used third-party ODBC drivers in the software market today and are backed by an award-winning technical support team.
A Few Practical Points
Use PHP function odbc_connect()to establish a connection to a database. This function accepts three required and one optional argument:
resource odbc_connect (string dsn, string user, string password [, int cursor_type]) U S I N G P H P
The dsn argument must be a Data Source Name. The user and password arguments identify the user. Finally, the optional cursor_type argument is used to specify, if necessary, which cursor method to use. For more information about this argument and PHP ODBC functions, consult the PHP documentation.
On Windows, the ODBC Administrator, available through the Control Panel, provides a GUI for creating a data source that stores connection option values. On UNIX and Linux, you store data sources in a file called odbc.ini. Instructions for defining a data source can be found in the DataDirect Connect and Connect XE for ODBC User’s Guide and Reference.
If, for example, you created a data source named DataDirectMSSQL for connecting to a Microsoft SQL Server database, and had a user name of sa and a password admin, you would use the following syntax in PHP:
$conn=odbc_connect("DataDirectMSSQL", "sa", "admin");
The $conn variable is a resource handle used to refer to this connection in subsequent code.
We have prepared detailed tutorials for you on how to connect ODBC drivers on Unix/Linux or Windows.
You can also try Connect for ODBC for free with our 15-day trial. Or if you prefer to have a quick chat first, contact us on our website or on Twitter at @DataDirect_News. We are always happy to help you.
View all posts from Zlata Palkovicova on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Copyright © 2019 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.