Jump to content


Photo

Best way too...


  • Please log in to reply
1 reply to this topic

#1 pbjorge12

pbjorge12
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 18 April 2006 - 03:17 AM

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?

#2 ypirc

ypirc
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 18 April 2006 - 05:32 AM

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.

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');

Does that help ?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users