note 74 modified in Oracle functions by ronabop

From: Date: Tue, 08 Aug 2000 19:23:20 +0000
Subject: note 74 modified in Oracle functions by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-682@lists.php.net to get a copy of this message
<h2>Oracle Example</H2> <h3>Prerequisites</h3> You need to know the values of the following environment variables:<p> <dl> <dt><b>ORACLE_HOME</b></dt> <dd>This is the path to your Oracle installation directory. It is usually defined in the UNIX login script of your oracle user and all Oracle client users.</dd> <dt><b>ORACLE_SID</b></dt> <dd>This is the name of the database instance you want to connect to. It is also defined in the UNIX environment of your oracle user and all Oracle client users.</dd> </dl> Find out the values of these variables by loggin in as a user who can connect to the database in question with sqlplus. Then type at your Unix shell prompt:<p> <pre> prompt> echo $ORACLE_HOME /opt/oracle/oracle/8.0.3 prompt> echo $ORACLE_SID ORACLE </pre> <h3>A simple PHP script using ora_* functions</h3> <pre> <?php putenv("ORACLE_SID=ORACLE"); putenv("ORACLE_HOME=/opt/oracle/oracle/8.0.3"); $conn = ora_login("scott", "tiger"); $curs = ora_open($conn); ora_commitoff($conn); $query = sprintf(&quotselect * from cat"); /* Long version */ /* ora_parse($curs, $query); ora_exec($curs); ora_fetch($curs); */ /* Short Version */ ora_do($conn, $query); $ncols = ora_numcols($curs); $nrows = ora_numrows($curs); printf("Result size is $ncols cols by $nrows rows.<br>"); for ($i=0; $i<$ncols; $i++) { printf("col[%s] = %s type[%d] = %s<br>", $i, ora_columnname($curs, $i), $i, ora_columntype($curs, $i)); } for ($j=0; $j<$nrows; $j++) { for ($i=0; $i<$ncols; $i++) { $col = ora_getcolumn($curs, $i); printf(&quotval[%d, %d] = %s * ", $j, $i, ora_getcolumn($curs, $i); } printf("<br>"); } ?> http://www.php.net/manual/oracle-functions.php

« previous php.notes (#682) next »