Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle and PHP question
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";
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.comReceived on Sun Mar 12 2006 - 20:46:38 CST