Jump to content

Archived

This topic is now archived and is closed to further replies.

pbjorge12

Best way too...

Recommended Posts

I am wodnering what the best way is too do this...
I have an sql class (ezsql) and an authentication class that gets its data from a database.

What is the best way to get the authentication class to use the sql class used throughout the rest of the site? Would it be to pass the sql object in the authentication class's constructor?

Share this post


Link to post
Share on other sites
Why don't you just require the class file and call it like you would any other time? Remember, classes are meant to be objects, you don't need to pass things around like that. For instance, let's assume a test authentication script...without actual code of course.

[code]
require 'sql.php'
<blah blah blah>
$sql = new sql();
$sql->function('hey');

OR ... if you decide to do your classes using the scope resolution operator, you'd do it like this:

require 'sql.php'
<blah blah blah>

SQL_CLASS_NAME::function('hey');
[/code]

Does that help ?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.