Connect Oracle with PHP

182 Views Asked by At

I have php project running on php version 8.1, installed on locale server ubuntu 20.4, in the server there is oracle 9i, Ive instlaled oracle instant client and im trting to connect php project to oracle db, i want to read data from oracle db

ive installed Oracle Instant Client 19.9 as well

    $user = "myusername"; 
    $password = "mypassword";
    $ODBCConnection = odbc_connect("Driver={Devart ODBC driver for Oracle};Direct=true;Host=myhost;Port=myport;Service Name=myservicename;User ID=myuserid;password=mypassword", $user, $password);

but im getting this error:

Failed to connect to database: ORA-03134: Connections to this server version are no longer supported.connected

if I have to upgrade the oracle, is there any else workarounds?

1

There are 1 best solutions below

0
Paul W On

You will not be able to connect to a 9i server using a 19c client, or any client newer than 11g. You really shouldn't be doing new development on something so legacy.

But if you have no choice, you can set up a passthrough database.

To do so:

  1. Choose an available (or install a new) 11.2.0.4 database somewhere (it does not need to be collocated either with your client or the target 9i server).

  2. Create a database link in the 11g passthrough to connect to the 9i database.

  3. Create views (views provide more functionality than synonyms) over each of the tables you need to work with, pointing to the 9i database through the @databse link. For procedures synonyms will work in most cases.

    E.g.:

    create view mytable as select * from mytable@my9ilink

    create synonym myproc for myproc@my9ilink

  4. Now connect your PHP program with the 19c client to the 11g passthrough database and interact with the views/synonyms that will redirect to the 9i. 11g can talk to both 9i and 19c, so this will work if set up correctly. I don't believe you can do this with 21c; 19c is probably your terminal version to connect to 11g.