|
Posted by Steph on 05/17/06 08:49
what is oci_define_by_name();
used for then?
"Mladen Gogala" <gogala@sbcglobal.net> a ιcrit dans le message de news:
tSrag.87539$dW3.68705@newssvr21.news.prodigy.com...
> Steph wrote:
>> Hello everyone,
>>
>> I have a question concerning oci_define_by_name();
>>
>> Why do I have to actually print all my variables prior to using them.I
>> mean if I don't use echo(); function in oci_fetch() function it seems the
>> value doesn't get into my variable....the value is not assigned to the
>> $variable...
>>
>> is it normal?
>>
>> here is an example of what I do:
>>
>>
>> //connection to database
>> include '../connection_DB/connect.php';
>>
>> $sql= "select a.request_name
>> ,a.request_date
>> ,c.request_type_name
>> ,c.request_type_id
>> ,a.request_wished_delivery_date
>> ,b.client_firstname||' '||b.client_lastname as client_name
>> ,b.client_id
>> ,d.brand_name
>> ,d.brand_id
>> ,a.request_comment
>> from requests a
>> ,clients b
>> ,request_types c
>> ,brands d
>> where a.request_client_id = b.client_id
>> and a.request_request_type_id = c.request_type_id
>> and a.request_brand_id = d.brand_id
>> and a.request_id = $reqID";
>>
>> $stmt = oci_parse($c1, $sql);
>>
>> // oci_define_by_name defines PHP variables for fetches of
>> SQL-Columns.Columns need to be
>> // in UPPERCASE with Oracle
>>
>> oci_define_by_name($stmt, "REQUEST_NAME", $up_req_name);
>> oci_define_by_name($stmt, "REQUEST_DATE", $up_req_date);
>> oci_define_by_name($stmt, "REQUEST_TYPE_NAME", $up_req_typ_name);
>> oci_define_by_name($stmt, "REQUEST_TYPE_ID", $up_req_typ_id);
>> oci_define_by_name($stmt, "REQUEST_WISHED_DELIVERY_DATE",
>> $up_req_wished_date);
>> oci_define_by_name($stmt, "CLIENT_NAME", $up_req_client_name);
>> oci_define_by_name($stmt, "CLIENT_ID", $up_req_client_id);
>> oci_define_by_name($stmt, "BRAND_NAME", $up_req_brand_name);
>> oci_define_by_name($stmt, "BRAND_ID", $up_req_brand_id);
>> oci_define_by_name($stmt, "REQUEST_COMMENT", $up_req_comment);
>>
>> oci_execute($stmt);
>>
>> while (oci_fetch($stmt))
>> {
>> // in white font not to display values on screen
>>
>> echo "<font color='#FFFFFF'> $up_req_name</font>";
>> echo "<font color='#FFFFFF'> $up_req_date</font>";
>> echo "<font color='#FFFFFF'> $up_req_typ_name</font>";
>> echo "<font color='#FFFFFF'> $up_req_typ_id</font>";
>> echo "<font color='#FFFFFF'> $up_req_wished_date</font>";
>> echo "<font color='#FFFFFF'> $up_req_client_name</font>";
>> echo "<font color='#FFFFFF'> $up_req_client_id</font>";
>> echo "<font color='#FFFFFF'> $up_req_brand_name</font>";
>> echo "<font color='#FFFFFF'> $up_req_brand_id</font>";
>> echo "<font color='#FFFFFF'> $up_req_comment</font>";
>>
>> }
> Steph, you don't need oci_define. You should simply use oci_fetch_array
> like this:
> //connection to database
> include '../connection_DB/connect.php';
>
> $sql= "select a.request_name
> ,a.request_date
> ,c.request_type_name
> ,c.request_type_id
> ,a.request_wished_delivery_date
> ,b.client_firstname||' '||b.client_lastname as client_name
> ,b.client_id
> ,d.brand_name
> ,d.brand_id
> ,a.request_comment
> from requests a
> ,clients b
> ,request_types c
> ,brands d
> where a.request_client_id = b.client_id
> and a.request_request_type_id = c.request_type_id
> and a.request_brand_id = d.brand_id
> and a.request_id = $reqID";
>
> $stmt = oci_parse($c1, $sql);
> if (!oci_execute($stmt)) {
> $err=oci_error($stmt);
> die($err['message');
> }
> list($request_name,
> $request_date,
> $request_type_name,
> $request_type_id,
> $request_wished_delivery_date,
> $client_name,
> $client_id,
> $brand_name,
> $brand_id,
> $request_comment)=oci_fetch_array($stmt,OCI_NUM);
>
>
>
> --
> Mladen Gogala
> http://www.mgogala.com
[Back to original message]
|