Page 1 of 1

pass class variables/arguments

Posted: Fri Feb 19, 2010 10:22 am
by dimxasnewfrozen
I'm somewhat new to the OOP methodoligies.

I'm trying to create a custom oracle database class. The php/oracle functions are odd..

I'm trying to do something like:
<?php
class db {

function connector() {
return $this->cisConnection = ocilogon("","","");
}

function parsed($cmdstr) {
$this->parsed = ociparse($this->connector(), $cmdstr);
}

function execute() {
ociexecute($this->parsed);
}

function nrows($cmdstr) {
$this->execute();
return ocifetchstatement($this->parsed, $results);
}
}
I'm not sure how to pass those variables as arugments within the class. That's what seems logical to me, but there's probably a completely methodology of doing it.

Re: pass class variables/arguments

Posted: Fri Feb 19, 2010 10:37 am
by dimxasnewfrozen
Hmm actually, all I had to do was modify it a little.

Code: Select all

 
<?php
class db {  
 
    function connector() {
        return $this->cisConnection = ocilogon("0","1","s");
    }
    
    function parsed($cmdstr) {  
        return $this->parsed = ociparse($this->connector(), $cmdstr);
    }
    
    function execute() {
        return ociexecute($this->parsed);   
    }
    
    function nrows($cmdstr) {
        $this->parsed($cmdstr);
        $this->execute();
        return ocifetchstatement($this->parsed, $results);
    }
}
?>
 
That works apparently, but i'm sure there's a better way to do that.

Re: pass class variables/arguments

Posted: Fri Feb 19, 2010 12:28 pm
by requinix
Still don't know what you're trying to do. Pass arguments to ocilogon in the connector()?
parsed() and nrows() are good examples of how to use arguments.

Or maybe you're talking about how to return values?