Skip to content

Instantly share code, notes, and snippets.

@ertuncefeoglu
Created September 24, 2013 10:45
Show Gist options
  • Save ertuncefeoglu/6683070 to your computer and use it in GitHub Desktop.
Save ertuncefeoglu/6683070 to your computer and use it in GitHub Desktop.
Calling Oracle stored procedures from PHP and binding parameters
<?php
public function runTestCollections() {
pre("SORGU BAÞLIYOR...");
$tarih = '20130401';
//$sonuc = array();
$SQL = "BEGIN TEST_COLLECTIONS(:TARIH, :SONUC); END;";
$stmt = $this->db->PrepareSP($SQL);
$this->db->InParameter($stmt,$tarih,'TARIH');
$this->db->OutParameter($stmt,$sonuc,'SONUC',-1, OCI_B_NTY);
$ok = $this->db->Execute($stmt);
pre("SORGU BÝTTÝ...");
pre($ok);pre($sonuc);die;
//$this->normalOci();
//return $rs;
}
public function normalOci(){
$c = oci_connect('ZDS', 'dt32xc29', 'TMQ');
$plsql = "BEGIN ADMIN_REPORT_TEST3(:BIR, :IKI, :SONUC); END;";
$s = oci_parse($c, $plsql);
$bir = 1;
$iki = 2;
oci_bind_by_name($s, ":BIR", $bir);
oci_bind_by_name($s, ":IKI", $iki);
oci_bind_by_name($s, ":SONUC", $SONUC, -1, OCI_B_INT);
$r = oci_execute($s);
if ($r) {
echo 'Procedure created';
}
pre("normal :".$SONUC);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment