oci8, php7 and Oracle 10.1 compatibility - php

I have to upgrade a system from php5.6 to php7.2. The system uses an oracle 10.1 database.
Now I tried to collect all infos but am still confused about the compatibility between php, oci8, instant client and the database.
I read, that with php7 I have to at least install oci8 2.1, but this doesn't work with oracle 10.1.
Is that correct?
Or is it possible to run php7 with oracle 10.1?
Please enlighten me :)

I read, that with php7 I have to at least install oci8 2.1, but this doesn't work with oracle 10.1.
Is that correct?
No. From the manual:
OCI8 2.0 requires Oracle 12c, 11g or 10g client libraries and will install on PHP 5.2 onwards.
Note that the Oracle client version you use doesn't need to match the server version. From the same manual page (reformatted into bullet points for ease of reading):
If OCI8 uses 9iR2 client libraries, then PHP can connect to Oracle Database 8i, 9iR2, 10g or 11g.
If OCI8 uses 10gR2 client libraries, the database can be 9iR2, 10g, 11g or 12c.
If OCI8 uses 11g client libraries, the database can be 9iR2, 10g, 11g or 12c.
If OCI8 uses 12c client libraries, the database can be 10gR2, 11g or 12c.
So only the last scenario (12c client libraries) requires a database version greater than 10.1.
Regardless of what the manual says, I would strongly recommend building a test instance and seeing if you have any issues.
Edit:
Further information from the OCI8 package PECL page:
Oracle's standard cross-version connectivity applies. For example,
PHP OCI8 linked with Instant Client 11.2 can connect to Oracle
Database 9.2 onward. See Oracle's note "Oracle Client / Server
Interoperability Support" (ID 207303.1) for details.

Related

Should one use FreeTDS driver instead of MS SQL Driver for compatibility between older PHP and newer SQL Servers?

I was struggling to connect my Drupal (7.43) application (hosted on a PHP 5.4 server) to a Microsoft Azure SQL database.
I got really depressed and even found myself arguing with my company's DBA for why did you install this database on the newest version of SQL Server?.
Edited:
The reason why I asked that was because of Microsoft official documentation which says one should not connect to newer versions of SQL Servers if PHP server version is under 7.*.
System Requirements for the Microsoft Drivers for PHP for SQL Server
https://learn.microsoft.com/en-us/sql/connect/php/system-requirements-for-the-php-sql-driver?view=sql-server-ver15#driver-versions
According to this article, if PHP server version is 5.4, the official MS driver for such php server is 3.2 version. Therefore, if the SQL Server driver is 3.2, it should not connect to SQL Server version higher than 2014.
TL; DR;
I used FreeTDS to connect 5.4 PHP application to Azure SQL Server! Yaay
FreeTDS is re-implementation of C libraries originally marketed by Sybase and Microsoft SQL Server. It allows many open source applications such as Perl and PHP (or your own C or C++ program) to connect to Sybase or Microsoft SQL Server.
My operational system is CentOS 7.
I installed basic yum packages for http server and php database connection.
yum install httpd httpd-tools php php-common php-cli php-odbc php-pdo unixODBC unixODBC-devel
So far I understand:
PDO stands for PHP Data Objects.
ODBC stands for Open Database Connectivity -- which is a standard application programming interface for accessing database management systems.
Alright, I then installed FreeTDS:
yum install epel-release
yum check-update
yum install freetds freetds-devel
Then I had /etc/freetds.conf:
[MYCLIENT]
host = myclient.database.edtech.com
port = 6669
tds version = 8.0 # Btw, how important is this version for old PHP servers versus new SQL servers?
I also had /etc/odbcinst.ini
[FreeTDS]
Driver = /lib64/libtdsodbc.so.0
FileUsage = 1
Furthermore, I had /etc/odbc.ini:
[MSSQLServer]
Driver = FreeTDS # Yes, ODBC will use FreeTDS, I get it.
Description = MSSQL Server
Trace = Yes
Server = myclient.database.edtech.com
Port = 6669
TDS_Version = 7.1 # Shouldn't this be same as the version in /etc/freetds.conf?
Database = ApplicationDB
Conclusions
I hope this question helps others.
FreeTDS is a different driver
than Microsoft's.
PHP does not know about FreeTDS not FreeTDS knows
about PHP version.
As far as I understood from the answers, there is
a ODBC bridge/layer in between them.
Better use the newest FreeTDS
version to make sure the connection works.
You said
The reason why I asked that was because of Microsoft official documentation which says I cannot connect to newer versions of SQL Server if my PHP version is below 7.*.
and
Is this php 5.4 connection really supposed to work with newest SQL
Server despite the official Microsoft docs say it should not?
...but actually, the Microsoft documentation you're talking about doesn't say you can't connect to SQL Server from PHP 5.4.
They said you can't (or at least you are not supported to) do that by using the Microsoft Drivers for PHP for SQL Server - which is the specific product that documentation is talking about.
FreeTDS is a different driver. By replacing the driver, you've replaced the thing which Microsoft is saying you shouldn't use. AFAIK Microsoft have no involvement with FreeTDS, so what they support, and what their driver works with, is entirely up to them.

Connect PHP to Oracle 12c on Oracle Linux 7.2

I have downloaded;
Oracle Linux 7.2
Oracle Database 12c for Linux
Oracle Instance Client for 12c
(All are of the same version)
What I was successful with;
Installing Oracle Linux on VMWare
Installing Oracle Database 12c
I need to;
Install LAMP with the capability of connecting to Oracle Database.
Install Instant Client with the capability of connecting php to Oracle Database.
Install phpmyadmin
Please Help ...
There are PHP RPMs (including one for the PHP OCI8 driver to connect to Oracle Database) at http://yum.oracle.com/oracle-linux-php.html
You will need to install the 'Basic' package from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html first (this requires a click-through so it can't be in a yum channel). It sounds like you have done this.
There's a lot of useful info about PHP OCI8 in the back half of this free book: http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html

Version of OCI8 and Oracle Instant Client

I've got:
Red Hat Enterprise Linux Server release 7.4 (Maipo)
PHP 5.4.16
Apache/2.4.6 (Red Hat Enterprise Linux)
Oracle12c DataBase
What version of OCI8 and Oracle Instant Client should I use?
Thanks a lot!
For PHP 5.2, 5.3, 5.4, 5.5 and 5.6 use the latest PHP OCI8 2.0 you can. Currently the most recent is 2.0.12 on https://pecl.php.net/package/oci8. Use 'pecl install oci8-2.0.12' to install it.
If your database is on a remote machine use Instant Client 12.2. Oracle Database supports client-to-server library version interoperability so you can use older or new Oracle client versions, if necessary. The latest client (12.2) has some improvements - of course!
If your database is on the same machine that PHP is on, you don't need Instant Client.

OCI8 configuration with WAMP64

I am trying to connect Oracle 11gXE with php. For php I downloaded wamp64 which is a 64bit version and the Oracle 11gXE is also 64bit. I am using windows 10 also 64bit.
Now I never connected Oracle to php so after searching a lot I found OCI and PDO_OCI among which OCI is recommended.
Now following steps were mentioned everywhere.
Download OCI thin client zip from oracle's official website.
Extract the zip
Include the path in environment variable.
Enable extension = php_oci8_12c.dll (or what ever oracle version you have) in php.ini
then use this $con = oci_connect($username, $password, $connection_string);
Now I have followed the steps, but failed to connect.
Following code to establish connection.
<?php
$username = "ABCD";
$password = "1234";
$connection_string = "localhost/XE";
$con = oci_connect($username, $password, $connection_string);
if(!$con) {
echo "Faild to connect";
}
else {
echo "Success";
}
?>
Now it show this error
So then I again I search to resolve this. Now I have faced following problems.
In my php.ini I didn't have php_oci8_11g.dll, I had php_oci8_12c.dl
And also had php_oci8_12c.dll in /ext.
So I downloaded php_oci8_11g.dll and mention extension = php_oci8_11g.dll.
Then try to run the code again but didn't work. Then in an article in here in stackoverflow I saw 32bit thin client is working because they had oracle 32bit and also xampp 32bit, But I have Oracle 11gXE 64bit and wamp 64bit also. So I have downloaded 64bit thin client.
Even I cannot see the php_oci8_11g in php extension pane.
php extension pane
Please help me with this what to do?
There are a few things to watch out for:
You need to make sure you have the same 32 or 64 bit architecture for all of: PHP, the webserver, the Oracle client libraries, and (if you are using Instant Client) also the MS VS Redistributable. (You did install the redistributable when you tried Instant Client? Check the Instant Client download page for details)
The version of the Oracle client libraries you want PHP to use (either in the Oracle XE installation, or from Instant Client) must be in PATH (and before any other Oracle version). Clashes between multiple version of libraries on Windows are hard to control. (Linux is easier...)
The version of the Oracle client libraries should be equal to, or greater than, the Oracle client version that the extension was compiled with E.g. php_oci8_12c was compiled with Oracle client 12c (but which will allow it to connect to older and newer database versions) so Oracle 12.1 or 12.2 client libraries must be in PATH (before other Oracle versions)
If you are downloading extensions from PECL, you need to make sure you get the thread safe, or non thread safe version of the DLL to match your PHP. And it must be for the same version of PHP you are using.

How to make OCI8 uses 9iR2client libraries on Linux?

I need to connect to an Oracle 8i server, but oci8 does not support it by default.
The php documentation says as following:
Note:
If OCI8 uses 9iR2 client libraries, then PHP can connect to Oracle Database 8i, 9iR2, 10g or 11g. If OCI8 uses 10gR2 client libraries, the database can be 9iR2, 10g, 11g or 12c. If OCI8 uses 11g client libraries, the database can be 9iR2, 10g, 11g or 12c. If OCI8 uses 12c client libraries, the database can be 10gR2, 11g or 12c.
How can I setup OCI8 to use 9iR2 client libraries?
My current environment is:
I'm on a ubuntu server,
Oracle 8i version 8.1.7.4.0
I have already installed instantclient libraries(I'm able to connect to oracle 10i and above)
I'm using instantclient version 12.1... Also tried with instantclient version 10.2
Could someone help me figuring out what the problem might be and how to solve it? Any help is really appreciated.
Thank you

Categories