Jump to content

Best way too...


pbjorge12

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?
Link to comment
https://forums.phpfreaks.com/topic/7681-best-way-too/
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 ?
Link to comment
https://forums.phpfreaks.com/topic/7681-best-way-too/#findComment-28057
Share on other sites

Archived

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

×
×
  • Create New...

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.