Hi Sheppard, I will try to answer what I can. (I am an oracle dba but a PHP newbie...:-) ) These will be the reader's digest version (high level). I will try to point you to oracle documentation for details (it comes on a CD, hope you have it!)
Q:If my PHP client is attaching to a remote oracle server, what do I need
to do (outside of PHP to get it to work)
A: Assuming that the database is created and running (see Database Admin guide), you need to run a properly configured "listener". (See the SQL*Net or Net8 or Networking Admin documentation from Oracle for configuration)
The listener process listens for incoming connections on a port (default 1521 I think) and routes them to the database by assigning a "server" process to the connection. The server process is neither the listener nor the database processes, but a separate process that exists to serve your connection (and possible others depending on how configured) until the connection is closed. You can see server procs on unix with ps -ef | grep oracle$ORACLE_SID (where $ORACLE_SID is your database name). For example, if your database is called DILBERT, do a ps -ef | grep oracleDILBERT. Example: oracleDILBERT (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq))). The actual stuff you see depends on how the listener is configured, and what type of connection it is, etc.
You also need to install the oracle OCI libraries on the machine which will be running PHP (eg, the web server, if different from the database machine). See the oracle installation guide for generall install info. You may need to choose a "custom" installation and just install those component. All those PHP oracle calls use these libraries.
Q: Why do I need TNSNAMES.ORA and SQLNET.ORA?
A: tnsnames.ora resides on each machine from which you want to connect to an oracle database. When you connect to a database using the userid/password@svcname syntax, the third parameter, sometimes called a database name, is REALLY a "service name" which may or may not be the same. This service name is contained within the tnsnames file on the machine FROM WHICH you are connecting to the remote database. The entry in the tns file expands the service name into the protocol (egTCP), the IP address or domain name, the database SID and the port of the listener process. In that way, your process knows where to go.
I haven't fiddled much with the sqlnet.ora....have just used default values... here is reveal net's description:
"The sqlnet.ora file contains the non-default options for the Net8 / SQL*Net installation. In most installations this file will be very small.
################
Filename......: sqlnet.ora
Node..........: italy2.italy.vod.telesis.com
Date..........: 07-DEC-94 10:09:09
################
TRACE_LEVEL_CLIENT = OFF
sqlnet.expire_time = 2147483647
names.default_domain = world
name.default_zone = world"
(Net8 or sqlnet is another piece installed on the client to facilitate communication with the listener. I am NOT SURE if this is needed when using PHP, though. - our sysadmin installed the stuff).
Q: Aren't those files used to run a local listener?
A: no tnsnames.ora defines how to get to a remote listener OR a local listener when the program connects using the "third parameter" - the service name.
the sqlnet.ora sets options for a client connection (sqlnet or net8) as above
the listener.ora file configures the local listener.
Q. Isn't a local listener to give remote users access to a local database??
I assume by local listener you mean running on the same box as the database? Yes. although you can also have database, listener and client all on one machine. In this case, the client can connect locally (no service name needed) or via the listener -- the same way as a remote connection -- even though it is on the same box.
Q. Aren't I really trying to connect to a remote listener, not a local one?
A: In general, yes. but you could also be connecting to a local one as described above. The basic rule is that any database that allows remote clients to connect, needs a listener. The listener usually runs on the same box as the database (I am not sure, but there may be other options -- I have not used them. Much of Oracle is very configurable and that is part of its complexity)
Q. If you are connecting to a remote server isn't the only way to get that to
work by using the third parameter (connect string) in OCI*Login.
A: Yes, because a remote connection requires the tnsnames, the listener, etc, and that requires that you supply the thrid param which is the service name.
Q. How does OCI Go about making and sustaining its connection? How many layers between request for login and actual authentication on the remote site.
Well, I think the layers (at a high level) are: OCI call -->sqlnet (resolves service name from tns) --> connects to listener port on remote machine --> listener assigns connection to a server process ---> which talks to the database engine on behalf of the client.
Hope that helped! Read the Oracle Concepts manual for a good intro to everything in general.
Hey if that helped, maybe you can help me -- see my question posted today.
Thanks!