pass class variables/arguments

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dimxasnewfrozen
Forum Commoner
Posts: 84
Joined: Fri Oct 30, 2009 1:21 pm

pass class variables/arguments

Post 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.
dimxasnewfrozen
Forum Commoner
Posts: 84
Joined: Fri Oct 30, 2009 1:21 pm

Re: pass class variables/arguments

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: pass class variables/arguments

Post 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?
Post Reply