473,781 Members | 2,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP 5.0.0 and the OCI8 module

I am relatively new to PHP, but with over a decade of experience in C
and other programming languages I can usually pick up a new
programming language relatively quickly (to be reasonably productive
not to know it inside out). My issues I believe may be either solely
concentrated on the platform I am running PHP 5.0.0 on (MS Windows
2000) or just the Oracle OCI8 module (running against an Oracle
8.1.7.4 installation). In either case I am using PHP in more of a
pure scripting environment with no Web-related access as of yet.

The following (with a modifications only for username and password) is
the script I just started developing:

<?php
$os_name = strtolower(PHP_ OS);
if (substr($os_nam e,0,3) == 'win') {
$dirsep = '\\';
$oci8lib = 'php_oci8.dll';
$pathsep = ';';
$libpath = 'PATH';
} else {
$dirsep = '/';
$oci8lib = 'oci8.so';
$pathsep = ':';
$libpath = 'LD_LIBRARY_PAT H';
}
$ORACLE_HOME = getenv('ORACLE_ HOME');
if (strlen($ORACLE _HOME) == 0) {
printf("The ORACLE_HOME environment variable has not been set\n");
exit(1);
}
if (!extension_loa ded('oci8')) {
$path = split($pathsep, getenv($libpath ));
$found = false;
foreach ($path as $dir) {
if (substr($dir,0, strlen($ORACLE_ HOME)) == $ORACLE_HOME) {
$found = true;
break;
}
}
if (!$found) {
printf("The OCI8 PHP module has not been autoloaded and
ORACLE_HOME\n") ;
printf("is not currently found in %-15s; therefore,
the\n",$libpath );
printf("OCI8 PHP module cannot be loaded at runtime.\n");
exit(1);
}
dl($oci8lib);
}
$DBA_HOME = getenv('DBA_HOM E');
if (strlen($DBA_HO ME) == 0) {
printf("The DBA_HOME environment variable has not been set\n");
exit(1);
}
$dfn = "${DBA_HOME}${d irsep}adm${dirs ep}databases.db ";
if ((!file_exists( $dfn)) || (!is_readable($ dfn))) {
printf("The DBA databases file:\n");
printf(" ${dfn}\n");
printf("is not available\n");
exit(1);
}
$dfh = fopen($dfn,'r') ;
if (!$dfh) {
printf("The DBA databases database:\n");
printf(" ${dfn}\n");
printf("is not available\n");
exit(1);
}
$dfd = fgets($dfh);
while (!feof($dfh)) {
$dfd = rtrim($dfd);
if ((strlen($dfd) > 0) && (substr($dfd,0, 1) != '#')) {
$dfa = split(':',$dfd) ;
$user = 'system';
$pass = 'manager';
$host = $dfa[0];
$port = $dfa[1];
$sid = $dfa[2];
$cnxn = oci_connect($us er,$pass,"(DESC RIPTION=(ADDRES S_LIST=(ADDRESS =(HOST=${host}) (PORT=${port})( PROTOCOL=TCP))) (CONNECT_DATA=( SID=${sid})))") ;
$stmt = oci_parse($cnxn ,'SELECT USER FROM dual');
oci_execute($st mt);
while ($data = oci_fetch_array ($stmt,OCI_ASSO C)) {
foreach ($data as $key => $value) {
printf("${host} ${sid} ${key} = ${value}\n");
}
}
oci_free_statem ent($stmt);
oci_close($cnxn );
}
$dfd = fgets($dfh);
}
fclose($dfh);
?>

The script is run on the command line as:
php oracle1.php

The file referenced in the script is in the following format:
host:port:sid:l evel1:level2:no tify
where host is the machine name, port the Oracle TNS listener port, sid
is the ORACLE_SID, level1 and level2 (not currently used in the
script) are percentages, and notify is an email address.

My two issues are as follows:
1. Although not the final purpose of the script, an interesting
phenomena occurs in which using "SELECT USER FROM dual" causes the
script to hang after the fclose. I know this because I have done the
simple debugging of printing messages at various points. If I change
the oci_connect to either oci_pconnect or oci_new_connect the script
completes successfully. Similarly, if the query is changed to
something other than including only the USER function (i.e. - "SELECT
USER, dummy FROM dual", "SELECT dummy FROM dual", "SELECT global_name
FROM global_name", etc.), whether oci_connect or either of the other 2
connection methods is utilized, the script also runs to completion.
My question is: what precisely is the "hanging" factor with regards to
using the simple "SELECT USER FROM dual" and oci_connect?

2. In attempting to deduce what had been going on in my script, I
found that regardless of which of the 3 connection methods I used
oci_close always returns a 0 (presumably indicating a FALSE result)
and oci_free_statem ent returns the expected result of 1 (TRUE). In
essence does oci_close either actually do anything or is it setup to
always return a FALSE? I realize that multiple database connections
in one script may not be the norm and that, as the oci_close
documentation indicates, that it normally is not necessary (as all
connections will be closed on script completion), but if said function
exists or it is expressly stated that multiple database connections
are not supported an oci_close should close the database connection.
I have no issues connecting and any other tool I use, commercial or
not, successfully closes the connection from my machine so it is
bizarre to me as well to always get the FALSE result.

I apologize in advance if this is more a newbie issue than actual
issues, but it is quite perplexing to me as a DBA and programmer as no
other programming environment I've worked on has had an issue as
described above.

Thank you.
Jul 17 '05 #1
0 2125

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
8494
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. 354 roberto@ausone:Build/php-4.3.2> ldd /opt/php4/bin/php libsablot.so.0 => /usr/local/lib/libsablot.so.0 libstdc++.so.5 => /usr/local/lib/libstdc++.so.5 libm.so.1 => /usr/lib/libm.so.1
0
3020
by: lok | last post by:
hi all, i have installed oracle9i client tools on RedHat7.3 (x86 machine) and i compiled php4.1.2 & apache1.3 successfully but when i execute php script in browser, error occured: "Fatal error: Call to undefined function: ocilogon()" i found no oci8.so in the whole system. i think this is the reason why the error occured
1
3383
by: watayoune | last post by:
Hi, My apache (on win) crash when i start it, after i had oci8 extensions in php.ini ! 1. i had extension phph_oci8.dll in php.ini 2. i've got a php_oci8.dll in my php extensions dir 3. my exetnsion dirs are c:\php\extensions\ in php.ini 4. i've installed oci8 client 5. i've put my oci.dll (from oracle_home) in my windows dir (tips found
8
4629
by: YeCkeL | last post by:
Warning: oci_new_connect() : OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in /wwwroot/htdocs/test.php on line 8 I am having this dump on my recent suse 10/oracle 10.2/apache 2.2.0/php5.1.2. Any ideas i pritty much used a uber basic. apache cfg line
6
6336
by: DravenStone | last post by:
Hi, I had just a horrible day at work, spent pretty much the entire day trying to get php_oci.dll and php_oracle.dll to load. It still never did. Super Quick Background. Jack of all trades IT guy, have written many tools using perl and JSP in the past. Had a chance to do a big project, and figured I would use it to learn PHP.
5
2879
by: Mladen Gogala | last post by:
The latest version of OCI8 1.2.1 doesn't work with LOB fields. There was an open bug, but Tony2001 was his usual helpful self, so he removed the bug and flatly denied its existence. I had to download 1.2.0 and reading CLOB fields started working again. Unfortunately, DBMS_METADATA.GET_DDL returns CLOB, so I was forced to discover this non-existing bug. PECL bug system is useless and maintainers are more suited for inquisitors then for...
5
8170
by: danish | last post by:
I download the oci-1.2.2.tgz file and generated the oci8.so file. After adding the extension=oci8.so in php.ini I get the error unable to load dynamic library /usr/lib/php4/oci8.so
0
4791
by: Yannick | last post by:
Hi, I'm Julien from France, We have recently install a new Web Server for my company The server is composed : - Linux RedHat RHEL4 U4 - Httpd-2.0.52-27.ent - Oracle Database 10.2.0.1
7
22089
by: eholz1 | last post by:
Hello All, I have reviewed various posts in regard to Oracle and PHP. I am running Apache 2.0.59, on Windows XP, with PHP 5.2. I would like to connect using PHP to a remote oracle db (ver. 7) I have uncommented out the php_oci8.dll and the older php_oracle.dll in the php.ini file the ini file resides in c:\php\php.ini
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10076
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9939
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8964
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7486
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2870
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.