Re: Mixing classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Tomi,

You could create an object of the Database class in your Auth class like this and then use your Datebase class with your Auth class:

<?php
require_once("Database/Database.php");

class Auth
{

var $dbObject = "";

function Auth ()
{
   //Create an instance of you database class
   $this->dbObject = new Database($arg1, $arg2, $etc);
}

function doSomething()
{
   // Execute a query
   $this->dbObject->query($sql);

}

}

?>

I hope this helps

Best regards,

Davy Obdam

Tomi Kaistila wrote:

Hey!

I've written several general classes, much as tools. One manages databases, one authenticates users, etc. I'm trying to bring all of these together into one sorta like a CMS, but the problem is that I can't find a way to have the different classes take advantage of each other; for example, a function in the auth class needs to contact the database, so it needs the query() function from the database class, but the objects are created on the index.php and as such are not in the scope of the functions in the classes.

Would anyone have any ideas or suggestions how to solve this issue? I've looked for a solution for some time now, to no result.

My PHP version is 4.3.8.


-- Davy Obdam mailto:info@xxxxxxxxxxxxx web: http://www.davyobdam.com

A conclusion is the place where you get tired of thinking. (Arthur Bloch)

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux