Jump to content

PHP/Oracle Procedure


Recommended Posts

Hello there,

Ok - Something a bit new for me. I am currently working on a site that uses PHP & Oracle. We have built a procedure where we need to.

Input:

  • Login ID Number (PHP Variable)
  • Current Server Date (sysdate in Oracle)

 

Output:

  • A list of messages from the Server

 

The Oracle side works & is tested. However we are getting problems when using the code:

$conn = OCILogon("****","****","****"); 
$curs = OCINewCursor($conn); 
$stmt = OCIParse($conn,"begin DISPLAY_MSG(_login_id, _date, _msg); end;"); 

OCIBindByName($stmt,"_login_id",&$gid,32);

OCIBindByName($stmt,"_msg",&$curs,-1,OCI_B_CURSOR); 

//$gid=1; // for gid = 1 only
//ociexecute($stmt); 
//ociexecute($curs); 

//while (OCIFetchInto($curs,&$friend_cv )) { 
//   echo "<pre>"; 
//    print_r($P_msg); 
//   echo "</pre>"; 
//} 

OCIFreeStatement($stmt); 
OCIFreeCursor($curs); 
OCILogoff($conn); 

 

However - I am stumped! I really don't know where to start, and need to know how to act with the procedure (input & output) and whether I can just use sysdate as the date.

 

Regards,

Matt

Link to comment
Share on other sites

Ok,

Im going somewhere now. My code looks like follows:

$ses_username = $sucid;
$ses_date = date('Y-m-d H:i:s',time());
$conn = OCILogon("user","password","server"); 
$curs = OCINewCursor($conn); 
$stmt = OCIParse($conn,"begin DISPLAY_MSG('$ses_username', '$ses_date', _msg); end;"); 

OCIBindByName($stmt,"_msg", &$ses_username, &$ses_date 20) or die ('Can not bind variable');  

OCIFreeStatement($stmt); 
OCIFreeCursor($curs); 
OCILogoff($conn); 

 

However I just get a blank screen, as soon as I comment OCIBindByName out it all works again.

 

Regards,

Matt

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.