Forum Moderators: coopster

Message Too Old, No Replies

PDO With Oracle stored procedure

         

SuMic

1:33 am on Apr 17, 2008 (gmt 0)

10+ Year Member



Basically I have an Oracle stored procedure which does a select and returns the cursor. I know how to user php oracle functions to process the cursor data returned. But I don't know how to do it with PDO.
here my codes
[codes]
<?
$sql1 = "begin pac_t_stock_affiche_title.pro_t_stock_affiche_title(:stockcode1,:rs);end;";
$stmt = $dbh->prepare("begin pac_t_stock_affiche_title.pro_t_stock_affiche_title(:stockcode1,:rs);end;");
$stockcode1 = '000001';
$stmt->bindParam(':stockcode1',$stockcode1, PDO::PARAM_INT, 100);
$stmt->bindParam(':rs',$rs,PDO::PARAM_STR, 100);
?>
[codes]
can not get the result $rs

thank u a looooooot~~

coopster

11:40 pm on Apr 17, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, SuMic.

It doesn't look to me like you have created an instance [php.net] of the pdo object yet.

SuMic

5:14 am on Apr 18, 2008 (gmt 0)

10+ Year Member



thank u coopster;
here my full code
<?
$dbh = new PDO('oci:host=127.0.0.1));dbname=stock', 'test', 'test');
$sql1 = "begin pac_t_stock_affiche_title.pro_t_stock_affiche_title(:stockcode1,:rs);end;";
//$sql1 = "CALL pac_t_stock_affiche_title.pro_t_stock_affiche_title(:stockcode1,:rs)";
$stmt = $dbh->prepare($sql1);
$stockcode1 = '000001';
$stmt->bindParam(':stockcode1',$stockcode1, PDO::PARAM_INT, 10000);
//$stmt->bindParam(':stockcode1',$stockcode1, PDO::PARAM_INT, 100);
$stmt->bindParam(':rs',$rs,PDO::PARAM_STR, 10000);
$stmt->execute();
$result = $stmt-> fetch();
//echo $stockcode1;
print_r($result);
?>