i need a ubuntu 20.04 server with php 7.4 to connect multiple version of oracle databases.
i installed the oracle instantclient in version 18.3 and load the oci8 php module.
for new version of oracle databases this works great. for older the connection failed.
these instantclient version is installed:
ii oracle-instantclient18.3-basic 18.3.0.0.0-4 amd64 Oracle Instant Client Basic package
ii oracle-instantclient18.3-devel 18.3.0.0.0-4 amd64 Development headers for Instant Client.
ii oracle-instantclient18.3-jdbc 18.3.0.0.0-4 amd64 Supplemental JDBC features for the Oracle Instant Client
ii oracle-instantclient18.3-odbc 18.3.0.0.0-4 amd64 Oracle Instant Client ODBC
this is the php version:
PHP 7.4.3 (cli) (built: Oct 6 2020 15:47:56) ( NTS
basically this version have to be supported:
oracle db 9.2.0.6.0
oracle db 9-0.1.3.1
oracle db 11g 11.2.0.1.0
oracle db 12c 12.2.0.1.0
oracle db 19c 12.2.0.3
oracle db 19c 19.0.0.0.0
this is the current code:
<?php
$dbstr ="(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST =<SERVERNAME>)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = <SRVNAME>)))";
if(!#($conn = oci_connect('<user>','<pass>',$dbstr)))
{
print_r(ocierror());
die("Connect Error");
}
?>
is it possible? i need some hint how to realize this
Oracle 9.0.1 is old. Like "gosh, look how many floppies this comes on" old. And it was a release that was pretty quickly desupported in favor of Oracle 9.2.
If you look at the Client/ Server Interoperability Matrix (Metalink account required), you have to go down to the extended matrix because the summary matrix doesn't even include 9.0.1 any longer. There, you'll see that the last version of the Oracle client that was compatible with a 9.0.1 database was 10.1.0. I'm pretty sure that predates the Oracle Instant Client so you'd probably need to install the full 10.1 client. You'll probably need to put in a support request to get access to versions of the client that old-- Oracle generally doesn't bother to make links to something that old available.
Assuming you do get a version of the client that is sufficiently ancient, it was certainly not certified on the version of Ubuntu or PHP you're using. It might install and work just fine. You might need to go with earlier versions of both.
I would strongly suggest going back to whatever lead to these requirements to make really, really sure that they understand the costs of supporting 20 year old software. If someone told you to build a new web site and to make sure that it was compatible with Firefox 2 (released in 2006), you'd point out that there would be pretty significant costs to trying to support a 15 year old browser doing so for very little gain-- there aren't a lot of Firefox 2 browsers left in the world. Oracle 9.0.1 is 5 years older than that and there are very, very few folks still running that version left in the world.
Related
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.
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.
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.
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.
I have a PHP app running happily on the following system:
web app: PHP version 5.2.3
OS: Windows Server 2003 Standard 32 bit
database: SQL Server 2005 (express)
web server: IIS 6
I'm trying to get the same thing running on the following:
web app: PHP version 5.2.11
OS: Windows Server 2008 Standard 64 bit
database: SQL Server 2008 Standard 64-bit
web server: IIS 7
After doing the install and setup I usually do, phpinfo() is running but there is no MSSQL section. I've looked around and found some MS documentation to set up the system using a php_sqlsrv.dll and tried that but it seems to use a different interface to connect to the database (no more mssql_connect(), now it's sqlsrv_connect()). Is this the only way to connect php to SQL Server 2008 or do I just have the setup wrong? If I can go back to PHP 5.2.3 and have it work, that will be fine but I didn't want to undo what I have if it won't help.
Thanks,
There is an extensive tutorial on MSDN on how to do this.
http://msdn.microsoft.com/en-us/library/cc793139%28SQL.90%29.aspx
The extension named php_mssql.dll is linked with an old Microsoft library (ntwdblib.dll). This library was last updated with MS SQL Server 6.5. It's a 32 bit library and does not support many of the new features introduced in newer versions of the database. It is possible to compile a version of the extension using FreeTDS. That will give access to the latest version of the TDS protocol. This also allows you to access SQL Server from a Linux/Unix based system.
The extension named php_sqlsrv.dll is developed and maintained by Microsoft gives much better support for the newer versions of SQL server and it should work in both the environments you describe.
There should be a dll named php_mssql.dll in the ext folder of your php installation. You will want to make sure this is being loaded in your php.ini file with extension = php_mssql.dll . If that is not showing in phpinfo() after restarting the webserver it may be that you have installed the wrong thread safe version of PHP depending on how you've set things up with Fast CGI. You shouldn't have a problem using sqlsrv (SQL Server Driver for PHP). I would however recommend using version 1.1 of the driver as it has some improvements and supports SQL Azure. One thing you will notice is that datetime columns come back as PHP DateTime objects instead of strings. I've also noticed that you run into a lot less problems if you just install the stack with the Microsoft Web Platform Installer.
After having this issue and almost tearing my hair out for hours and giving up, I found the answer:
http://docs.moodle.org/22/en/Installing_MSSQL_for_PHP#Using_FreeTDS_on_Windows
php_dblib.dll is the "new" dll that supports the old mssql php functions (mssql_connect() etc). So basically this new dll replaces php_mssql.dll and everything just works as it did before. (Well it does for me now)
My server setup is:
O/S: Windows Server 2008,
DB: MSSQL Server 2008 R2,
PHP: 5.3.13
Excerpt from phpinfo():
System Windows NT XXXXXXXXXXXXX 6.1 build 7601 (Windows Server 2008 R2
Enterprise Edition Service Pack 1) i586 Build Date May 8 2012 18:41:52
Compiler MSVC9 (Visual C++ 2008) Architecture x86
Configure Command cscript /nologo configure.js
"--enable-snapshot-build" "--enable-debug-pack" "--disable-zts"
"--disable-isapi" "--disable-nsapi" "--without-mssql"
"--without-pdo-mssql" "--without-pi3web"
"--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared"
"--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared"
"--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared"
"--with-enchant=shared" "--enable-object-out-dir=../obj/"
"--enable-com-dotnet" "--with-mcrypt=static"
"--disable-static-analyze"
Server API CGI/FastCGI
Virtual Directory Support disabled
Configuration File (php.ini) Path C:\Windows
Loaded Configuration File C:\Program Files (x86)\PHP\v5.3\php.ini
Hope this saves someone some time.