PHP Class Trouble

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amanjsingh
    New Member
    • Mar 2007
    • 48

    PHP Class Trouble

    I am new to OOPS esp in PHP and I am stuck here -

    I have a file called dat.php which has a class defined in it. This class has usual functions for database connectivity and error reporting if not connected etc. I use this file anywhere in my application I want to connect to my database.

    The constructor is

    Code:
    	function DB {
           $this->host = 'XXXXXXXX';
           $this->user = 'XXXXXXXX';
           $this->password = 'XXXXXXXXXX';
           $this->database = 'XXXXXXXX';
           $this->persistent = false;
    
    	}
    Problem is that I have to encrypt the password (using another encryption function) and retrieve it from another file and I do not want to put username and password here in this file and I do not know how to do that. I definitely cannot remove this class as it has been used at a lot of places.


    Can anyone help please?

    Thanks,
    AJ
  • amanjsingh
    New Member
    • Mar 2007
    • 48

    #2
    Well, I came to know that base class constructor does not automatically pass to the derived class. So I put my username and password in a class in some different file. Included this file in the dat.php and in the constructor of the class DB{} I used this =
    Code:
    class DB extends DB_p {
    
    function DB {
    parent::DB_p();
    }
    }
    Any suggestions if this secure?

    Thanks
    AJ

    Comment

    Working...