PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

OCIResult> <OCIParse
Last updated: Sun, 25 Nov 2007

view this page in

OCIPLogon

(PHP 4, PHP 5, PECL oci8:1.0-1.2.4)

OCIPLogon — 오라클 데이터베이스에 접속하고 영속적 DB 접속 (persistant connection) 을 이용해서 로그온한다. 또다른 새로운 세션(session)을 넘겨준다.

Description

int OCIPLogon ( string $username , string $password [, string $db ] )

OCIPLogon() 오라클8 DB에 영속적인 접속을 형성하고, 로그온 한다. 세번째 인수는 로컬 오라클 인스턴스(local Oracle instanace)의 이름, 또는 tnsnames.ora설정파일의 엔트리(entry) 이름이 될수 있다. 세번째 인수가 생략되면, PHP는 접속할 오라클 데이터베이스를 결정하기 위해 환경변수 ORACLE_SID (Oracle instance)나 TWO_TASK(tnsnames.ora)를 이용한다.

See also OCILogon() and OCINLogon().



OCIResult> <OCIParse
Last updated: Sun, 25 Nov 2007
 
add a note add a note User Contributed Notes
OCIPLogon
M0no at ethonfusino dot com
21-Nov-2002 10:04
If your oracle database is on a remote system within your local network and you don't want to worry about the tnsnames file you can try this.

$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.XX.XXX)(PORT = 1521)))(CONNECT_DATA=(SID=XXXX)))";

$c1 = ocilogon("name","password",$db);

Hope this helps someone.
kakukkfu at mailbox dot hu
26-Sep-2002 11:09
Better to insert needed variables into apache(!) (or your webserver - respectively) start script.

For example on UNIX systems /etc/init.d/apache would contain following lines before anything else:

#!/bin/bash

if [ -f ~oracle/.profile ]; then
        source ~oracle/.profile
fi

The ~oracle/.profile has the appropiate settings to start an Oracle database so it is always up-to-date for PHP, too. (If settings are changed, don't forget to restart your webserver.) This way you just no need to worry what to include or define for PHP.
e dot v dot wijk at hetnet dot nl
06-Apr-2001 07:26
The solution for not being able to connect to an Oracle database usually is setting the right system variables (ORACLE_HOME, etc...). However, it often happens that you are still not able to connect, even though these settings are correctly set.

If this is the case, try the following:

Instead of refering to the entry in the tnsnames.ora, use the actual string from the tnsnames.ora:

$User = "john"
$Password = "doe"
$Database = "(DESCRIPTION = ADDRESS_LIST (ADDRESS = (PROTOCOL= TCP (Host= yourhost) (Port= 1526)))(CONNECT_DATA = (SID = YourTnsSID )))";

OCIPLogon($User, $Password, $Database)

I hope this is helpfull for those strugling to connect to an Oracle database.

Edwin van Wijk
steve at stevedix dot de
07-Feb-2001 07:17
IF you're wondering exactly what you are dealing with, here's a brief explanation:  Oracle is NOT like mysql, which makes it very easy to connect between databases.  Oracle uses a product called sql*net to control connection between remote machines, clients and databases.  It is capable of operating on multiple different network protocols, and requires listeners to be configured for the network protocol you plan to use (usually tcp). This system has its own domain name system which rationalises database names with machines (which is why you don't have a host variable in the OCIPlogin). Configuring these listeners is not easy and requires the editing of two files tnsnames.ora and sqlnet.ora.  Even more important is to make sure that the oracle environment variable TNS_ADMIN points to the place where you put tnsnames.ora and sqlnet.ora

A good place to start reading about this is

http://www.atr.net/faq/software/FRONT_END/faqnet.htm

A more detailed version can be found at :

http://www.orafaq.net/faqnet.htm

Bear in mind that this is an incredibly complex product and not something that you should really be playing with if you don't know what you're doing.  I've seen (otherwise) experienced oracle admins baulk at configuring sql*net.  Pat solutions (like the one above) cannot be used verbatim - you will need to know and substitute several symbolic names.

HTH
michel at diefirma dot de
02-Aug-2000 12:03
After hours of weird searching and "try an error"-games with oracle and php I've got my working system with connection to a remote oracle server. Yeah! Documentation is very bad for this topic and the posts in all the mailing lists are very confusing. But now...

cheers. it works!

here my working sample code (php4 on debian, oracle 8.1.5.0.2 client, oracle 8i enterprise server on win2k)

michel

<?php
$user
= "scott";
$pass = "tiger";
$tns_name = "my_service_name_in_tnsnames.ora";

// set ORACLE Dir to get the NET8 name resolver working
// tnsnames.ora has to be in $ORACLE_HOME/networking/admin/
putenv("ORACLE_HOME=/home/oracle01/app/oracle/product/8.1.5");

// log on to oracle server using data above
$db_id = OCILogon ($user, $pass, $tns_name);
?>

OCIResult> <OCIParse
Last updated: Sun, 25 Nov 2007
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites