Class file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post by shivam0101 »

wrote 3 separate class. Admin, Member and Sql

The Sql class contains all the methods of sql statements, like INSERT, DELETE etc.

The Admin contains all the methods which are needed for admin

The Member contains all the methods which are needed for Member

How to connect all? Currenty i created a class called Cls in which i have declared all the methods which are in the 3 classes (Admin, Member and Sql), and redirecting to the relevant class.

for example,

to access member name, which is defined in Member class i will be calling,

Code: Select all

$member_obj=new Cls;
$member_obj->memberName($id);
In the Cls class,

Code: Select all

function MemberName($id)
{
    return Member :: MemberName($id);
}
In the Member class,

Code: Select all

function MemberName($id)
{
    $name=Sql :: Get($tblName, "WHERE id=$id");
    return $name['member_name'];
}
In the Sql class,

Code: Select all

function Get($tblName, $cond)
{
  $query=mysql_query("SELECT * FROM $tblName WHERE $cond");
  return mysql_fetch_row($query);
}
Which looks clumsy, It should be linked in a better way, can some one give me some idea to link and call the class
Post Reply