Calling ORACLE procedure from PHP big problem!!!
Posted: Tue Jan 10, 2012 1:38 pm
Hi guys it's my first post here so please help if you know how to handle this problem.
I am developing php scripts that I will call with certain methods from another programming language but this is not important right now... Because I am trying to make my code work from php page first.
So I am using php to connect to Oracle database, I have few scripts, I will put the code in but not all of it so if you need more details please ask.
First I have this class, for communicating with Oracle database ( this is whole file ):
Then I have this class that is making me phonebook class ( sorry if it's not in english) but I think you'll be able to see what is what inside ( i will just post few functions )....
As you can see I have tried several ways of executing this code but it doesn't work.
These variable I get from another class and I have constructor like this:
So basically I am getting all kind of error's. So If anyone can give me some info about what is incorrect and what to do. So I want call certain stored procedures in oracle database from php code.
Thank you in advance,
Denonth
I am developing php scripts that I will call with certain methods from another programming language but this is not important right now... Because I am trying to make my code work from php page first.
So I am using php to connect to Oracle database, I have few scripts, I will put the code in but not all of it so if you need more details please ask.
First I have this class, for communicating with Oracle database ( this is whole file ):
Code: Select all
<?PHP
class oracle_baza {
static function Exec($query) {
//otvaranje konekcije s bazom
$conn = oci_connect(
$GLOBALS['cfg_db_User'],
$GLOBALS['cfg_db_Pass']
);
if($conn === false) {
throw new Exception(oci_connect_error());
}
//izvedemo query
$s = oci_parse($conn, $query);
$rez = oci_execute($s);
if(is_bool($rez) && !$rez) {
//greska
$napaka = oci_error($conn);
oci_close($conn);
throw new Exception($napaka);
}
//zatvorimo konekciju
oci_close($conn);
return $rez;
}
?>Code: Select all
//funckija za pohranjivanje podataka
function Dodaj_korisnika(){
$query="CALL Dodaj_korisnika('$this->ime_korisnika','$this->prezime_korisnika','$this->broj_telefona','$this->adresa')";
$result=$this->connector->Exec($query);
}
//funkcija za brisanje
function Brisanje_korisnika(){
$query='BEGIN Brisanje_korisnika(:id_korisnika);END;';
oci_bind_by_name($query,':id_korisnika',$this->id_korisnika,32);
$result=$this->connector->Exec($query);
}
//funckija za update podataka
function Update_korisnika(){
$query="CALL Update_korisnika('$this->id_korisnika',$this->ime_korisnika','$this->prezime_korisnika','$this->broj_telefona','$this->adresa')";
$result=$this->connector->Exec($query);
}These variable I get from another class and I have constructor like this:
Code: Select all
public function __construct($id_korisnika,$ime_korisnika, $prezime_korisnika, $broj_telefona,$adresa) {
$this->id_korisnika = $id_korisnika;
$this->ime_korisnika =$ime_korisnika;
$this->prezime_korisnika = $prezime_korisnika;
$this->broj_telefona = $broj_telefona;
$this->adresa = $adresa;
$this->connector = new oracle_baza();
}Thank you in advance,
Denonth