RE: PHP Scripts and Oracle instantclient

  • From: "Goulet, Richard" <Richard.Goulet@xxxxxxxxxxx>
  • To: <martin@xxxxxxxxxxxxxxxx>, <oracle-l@xxxxxxxxxxxxx>
  • Date: Wed, 7 Oct 2009 23:35:45 -0400


        There is a way to link PHP and the Oracle Instant client, but I
have not gotten it to work, yet.  The easier thing to do is load a full
client with the OCI libraries.  Should not be a cost issue, since
clients are not licensed, but it will burn more disk space. 

Dick Goulet
Senior Oracle DBA/NA Team Lead
PAREXEL International

-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx
[mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Martin McCormick
Sent: Wednesday, October 07, 2009 3:25 PM
To: oracle-l@xxxxxxxxxxxxx
Subject: PHP Scripts and Oracle instantclient

I an very glad to now be on the list so I can show my ignorance
to the entire world. Thanks to all those who solved the
technical problems that kept a few of us from being able to
request posting permission.

        I installed sqlplus on a ubuntu system via the Oracle
linux-instantclient and it appears to be working in that I can
now connect to the Oracle database we need on a remote server.
The instantclient software will run oracle scripts but what I
have on hand are some php scripts that use embedded oci commands
to execute the Oracle commands. Here is part of a script:

//open connection to database
 //Get The sysdate from database
$sql = "Select to_char (sysdate, 'MM/DD/YYYY HH:Mi AM') as date1 from
$stmt = ociparse($conn,$sql);
while (ocifetch($stmt)){
        $update_timestamp = ociresult($stmt, "DATE1");
//close the connection to the database
$cursor = ora_open($ora_conn); // Create a cursor
$pin_processed = 'Y';
snip _________________

        These scripts were transplanted from a Windows system
and the php it ran speaks oci_x commands. If you install the
native php5 package in Linux, it just errors out because it
doesn't know this business about oci.:-)

        You can apparently make php know this by getting the
sources and building from source in an environment that has the
right Oracle libraries. This makes life harder each time there
is an upgrade.

        Is it possible to use sqlplus to do the Oracle data
manipulation and then php to transport data from one system to

        We are basically gathering data from the Oracle server,
examining and updating certain fields, and then copying data to
yet another system. The only Oracle part is to access the
Pinnacle 6 server that has the Oracle data base.

        If this all sounds confusing, I am not yet familiar with
either Oracle or php but having to make a special build of php
each time sounds like a recipe for trouble. After you get
something like that working once, people start to depend on it
and you are just one upgrade away from dead in the water and who
knows why?

        sqlplus appears to work fine and native php also works
and if we can divide and concur, life should be a little less on
the bleeding edge.

        Any thoughts are much appreciated and, if I am wrong
about php under Linux, I want to know that also.

Martin McCormick WB5AGZ  Stillwater, OK 
Systems Engineer
OSU Information Technology Department Telecommunications Services Group


Other related posts: