Is there a thin driver for Oracle available to be used with PHP (for example as an extension)?
I cannot install the OCI driver/client, but need to be able to access an Oracle database.
What is the problem with installing the OCI driver ?
The InstantClient version simply requires an unzip and setting a couple of environment variables.
The other option is exposing the database functionality through web services. 11g includes an inbuilt HTTP server.
Oracle released a jdbc driver written only in java, but (afaik) without the source code, so I doubt they will release a php (source code) driver. And never heard of an attempt by someone else.
But another question: "(for example as an extension)" You would be able to install an extension but not the oci8 extension?
There is no "thin" Oracle driver in PHP. You always need an external client library such as Oracle Instant Client - which is really easy to install.
Check http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf
(Also, Oracle has RPMs of PHP and Instant Client that can be used on RH Linux.)
Related
Is there a PHP buildpack out there which I can use which has the DB2 extensions and the SSL for the DB2. I have been searching for it and tried using the PHP Buildpack, but with no luck to connect to the DB2.
Any suggestion is appreciated.
Thanks
I haven't tested that but you should be able to use the standard PHP builpack that comes with IBM Cloud and its Cloud Foundry.
The PHP buildpack allows to configure extensions to be downloaded. If you add ibm_db2.so as extension, it should be considered as it is part of the regular PHP ecosystem. Another Db2 driver is PDO_IBM.
My question is based off of this post's answer from #Crontab. I downloaded SQLSRV40 from Microsoft website. When I try to install it is asking for
When I install, I have to enter a path to extract files and as it mentions in the website under installation instructions No.3 "When prompted, enter the path to the PHP extensions directory".
I have xampp and there is a php file directory. For my extracting path should I just give 'C:/xampp/php'?
I am a bit confused because, the under the comment section in the answer, #Crontab mentioned "My guess would be wherever you find all the other php_*.dll files". This means all the php_*.dll files should be under php folder right?
Also, say, if I extract them into that folder or different folder, when I added php_pdo_sqlsrv_7_nts_x64 into my php.ini folder and connected via apache I could not find my pdo_sqlsrv dll.
This is my first time installing SQL server drive. Any suggestion would be appreciated.
Seeming like main issue was sqlsrv drivers available for download on Microsoft sites currently only support PHP 7.0.+, i.e. not PHP 7.1 or 7.2.
The solution is to either download newer drivers (https://github.com/Microsoft/msphpsql/releases support for 7.2 but labeled as "technical preview") or to downgrade to PHP version 7.0.
Other common gotchas are:
Failing to download the additional required Microsoft ODBC drivers.
Confusion over x86 and x64 versions of drivers (also ts/nts "thread safe" and "non thread safe"). Will depend on your system/php install.
Also seeing that pecl offers the 'preview' versions of the drivers: https://pecl.php.net/package/pdo_sqlsrv/5.0.0/windows
There they also offer up this useful description:
The Microsoft Drivers for PHP for SQL Server are PHP extensions that allow for the reading and writing of SQL Server data from within PHP scripts. The SQLSRV extension provides a procedural interface while the PDO_SQLSRV extension implements PDO for accessing data in all editions of SQL Server 2008 R2 and later (including Azure SQL DB). These drivers rely on the Microsoft ODBC Driver for SQL Server to handle the low-level communication with SQL Server.
I have two RHEL servers, one to host the PHP application, one to host the MySQL server.
Database server has MySQL Enterprise version 5.6.21 installed.
While getting the application server built, I asked that the rpm MySQL-client-advanced-5.6.21-1.el6.x86_64 be installed (to match server), but the hardware people don't like this version since 5.6.27 is available which addressed some vulnerabilities.
The question is the following:
Does the mysql client version on the application server affect the database queries coming from the PHP application?
We're using PDO to connect to and query MySQL.
If we do this, does the application server even need a mysql client library?
Please let me know if I can clarify.
Thanks!
PHP uses its own library/driver to connect to MySQL databases. The MySQL-client-advanced package is just the CLI mysql client. PHP does not use this.
For PHP (and PDO), you should install php-pdo and php-mysqlnd. php-mysqlnd is the "MySQL native driver" and contains some enhancements. It also contains the mysqli class and the pdo-mysql connector.
Note: php-mysqlnd versions are unrelated to the MySQL server version.
Quote from the Mysql website
MySQL Native Driver is a replacement for the MySQL Client Library (libmysqlclient). MySQL Native Driver is part of the official PHP sources as of PHP 5.3.0.
https://dev.mysql.com/doc/apis-php/en/apis-php-mysqlnd.html
I am running a LAMP server but now need to connect to MS SQL (client request). I have heard Microsoft has a driver, but can't verify if
Does anyone know if the Microsoft driver is available for Unix? If not, should I just stick with FreeTDS? This appears to be recommended by PHP, however install documentation seems lacking. Any direction on either would be greatly appreciated.
Sorry for the general question, I am not familiar with setting up PHP drivers.
UPDATE
Just for some back story, I am running an intranet from the LAMP server but needs to connect to a datasource on an external MS SQL DB Server (Windows of course). I am running PHP5.
FreeTDS is fine and works well enough. The Microsoft driver is Windows only, thus you wouldn't be able to use it on your Linux server.
First install FreeTDS and then configure PHP with --with-mssql=/prefix/used/for/freetds. If you are using your distribution's PHP, I'm sure there is a MS-SQL driver package already precompiled and available for installation (in Ubuntu, that'd be php5-sybase).
Then use PHP's mssql_* functions to actually do the work
For anyone who comes across this rather old question...
It should be noted that since 2010, Microsoft has actually developed a viable Linux driver for SQL Server that is installable via PECL. It's currently only compatible with PHP 7.
The main readme file is here, which lists some general and overly complicated installation instructions. But if you look at the latest release notes you will see that newer versions can be installed via PECL like so:
sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv
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.)