Air_Mike Posted August 29, 2007 Share Posted August 29, 2007 Hello, i would really appreciate if someone could help me here. It'a about calling oracle stored procedure with some input and output parameters. I have this working using ADODB class, but now I need the same thing using PDO Extension. It's all ok when output parameter is some value accept cursor. This is code working with ADODB: $conn_thor = newADOconnection("oci8"); $conn_thor->connect(_connection parameters_); $stmt = $conn_thor->PrepareSP("BEGIN PKG_THOR.GET_USER_ROLES_AUTH (:ulaz1, :ulaz2, :ulaz3, :crsr, :izlaz); END;"); $conn_thor->InParameter($stmt, $login, 'ulaz1'); $conn_thor->InParameter($stmt, $GLOBALS["apl_sifra"], 'ulaz2'); $conn_thor->InParameter($stmt, $_SERVER['REMOTE_ADDR'], 'ulaz3'); $conn_thor->OutParameter($stmt, $cur, 'crsr', -1, OCI_B_CURSOR); $conn_thor->OutParameter($stmt, $izlaz, 'izlaz'); $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $array_user_role = $conn_thor->GetArray($stmt); With this I have two outputs. $izlaz is integer, and $array_user_role i array of roles for user. Now I need to do this using PDO. try { $conn_sso = new PDO(_connection parameters_); $ulaz1 = 'admin'; $ulaz2 = 'A901'; $ulaz3 = $_SERVER['REMOTE_ADDR']; $stmt = $conn_sso->prepare("CALL PKG_THOR.GET_USER_ROLES_AUTH (:ulaz1, :ulaz2, :ulaz3, :crsr, :izlaz)"); $stmt->bindParam(':ulaz1', $ulaz1, PDO::PARAM_STR); $stmt->bindParam(':ulaz2', $ulaz2, PDO::PARAM_STR); $stmt->bindParam(':ulaz3', $ulaz3, PDO::PARAM_STR); $stmt->bindParam(':crsr', $crsr, ????here is the problem????); $stmt->bindParam(':izlaz', $izlaz, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT , 4); $stmt->execute(); echo "izlaz: " . $izlaz; $conn_sso = null; } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } Thank You.... EDITED BY akitchin: code tags are not only fancy and stylish, but they now increase fertility by 80%! try them today! Quote Link to comment https://forums.phpfreaks.com/topic/67236-php-pdo/ Share on other sites More sharing options...
Air_Mike Posted August 30, 2007 Author Share Posted August 30, 2007 I manage to do this with oci functions in PHP... $ulaz1 = 'admin'; $ulaz2 = 'A901'; $ulaz3 = $_SERVER['REMOTE_ADDR']; $conn_sso = oci_connect("log040", "log040", "logora"); $stmt = oci_parse($conn_sso, "BEGIN PKG_THOR.GET_USER_ROLES_AUTH (:ulaz1, :ulaz2, :ulaz3, :crsr, :izlaz); END;"); oci_bind_by_name($stmt, ":ulaz1", $ulaz1); oci_bind_by_name($stmt, ":ulaz2", $ulaz2); oci_bind_by_name($stmt, ":ulaz3", $ulaz3); $curs = oci_new_cursor($conn_sso); oci_bind_by_name($stmt, ":crsr", $curs, -1, OCI_B_CURSOR); oci_bind_by_name($stmt, ":izlaz", $izlaz); oci_execute($stmt); oci_execute($curs); oci_fetch_all($curs, $user_roles, "0", "-1", OCI_ASSOC+OCI_FETCHSTATEMENT_BY_ROW); echo "izlaz: " . $izlaz; print_r($user_roles); oci_free_statement($stmt); oci_free_statement($curs); oci_close($conn); I still don't know how to do this with PDO.... EDITED BY akitchin: code tags are the truth, the light, the way. Quote Link to comment https://forums.phpfreaks.com/topic/67236-php-pdo/#findComment-337717 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.