Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle and PHP question

Re: Oracle and PHP question

From: Mladen Gogala <gogala_at_sbcglobal.net>
Date: Mon, 13 Mar 2006 02:46:38 GMT
Message-Id: <pan.2006.03.13.02.46.37.401476@sbcglobal.net>


On Fri, 10 Mar 2006 19:32:29 +0100, Steff wrote:

> // connexion
> $conn = ocilogon("stephane","Stef1975",$bdtest05);
> // préparation du Select
> $query="select a.fulfiller_firstname|| ' '||a.fulfiller_lastname
> ,b.request_type_name
> ,c.task_name
> ,c.task_start_date
> ,c.task_end_date
> ,d.request_wished_delivery_date
> ,e.client_firstname||' '||e.client_lastname
> from fulfillers a
> ,request_types b
> ,tasks c
> ,requests d
> ,clients e
> where c.task_fulfiller_id = a.fulfiller_id
> and c.task_request_id = d.request_id
> and d.request_request_type_id = b.request_type_id
> and d.request_client_id = e.client_id;";
>
> $ordre = OCIParse ($conn, $query);
> OCIExecute ($ordre);
> $ncols = OCINumCols($ordre);
> // affiche les lignes tant qu'il y en a
> // et les colonnes une par une
> print "<TABLE BORDER=1> ";
> print "<TR>";
> print "<TD>Fulfiller</TD>";
> print "<TD>Request Type</TD>";
> print "<TD>Task Name</TD>";
> print "<TD>Start Date</TD>";
> print "<TD>End Date </TD>";
> print "<TD>Expected Delivery date</TD>";
> print "<TD>Client</TD>";
>
> while (OCIFetchInto ($ordre, $ligne, OCI_NUM)) {
> print "<TR> ";
> for ( $i=0;$i < $ncols; $i++) {
> print "<TD> $ligne[$i] </TD>" ;
> }
> print "</TR> ";
> }// libere les ressources
> OCIFreeCursor ($ordre);
> OCILogoff($conn);
> ?>

Stefane, you didn't say which version of PHP are you using, but this definitely looks like OCI and not OCI8. Unfortunately, I don't understand French so I cannot help you with the comments, but here is an analogous code in PHP 5.1.2 and OCI8:

<?php
$conn = oci_connect("scott", "tiger", "local"); // php_beautifier->setBeautify(false);
$query = "SELECT empno||' '||ename ,job ,hiredate

          FROM emp
          WHERE deptno>0";

// php_beautifier->setBeautify(true);
$sth = oci_parse($conn, $query);
oci_execute($sth);
$ncols = oci_num_fields($sth);
while ($row = oci_fetch_array($sth)) {

    for ($i = 0;$i<$ncols;$i++) {

        printf("%s\t", $row[$i]);
    }
    print ("\n");
}
?>

As you can see, I use concatenation as well and it works like a charm:

$ ./ttt

7369 SMITH      CLERK   17-DEC-80
7499 ALLEN      SALESMAN        20-FEB-81
7521 WARD       SALESMAN        22-FEB-81
7566 JONES      MANAGER 02-APR-81
7654 MARTIN     SALESMAN        28-SEP-81
7698 BLAKE      MANAGER 01-MAY-81
7782 CLARK      MANAGER 09-JUN-81
7788 SCOTT      ANALYST 19-APR-87
7839 KING       PRESIDENT       17-NOV-81
7844 TURNER     SALESMAN        08-SEP-81
7876 ADAMS      CLERK   23-MAY-87
7900 JAMES      CLERK   03-DEC-81
7902 FORD       ANALYST 03-DEC-81
7934 MILLER     CLERK   23-JAN-82


-- 
http://www.mgogala.com
Received on Sun Mar 12 2006 - 20:46:38 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US