How to connect all the class files to access data easily?
Posted: Mon Jul 02, 2007 12:07 am
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,
In the Cls class,
php:
In the Member class,
php:
In the Sql class,
php:
Which looks clumsy, It should be linked in a better way, can some one give me some idea to link and call the class
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
php:
$member_obj=new Cls;
$member_obj->memberName($id);In the Cls class,
php:
Code: Select all
function MemberName($id)
{
return Member :: MemberName($id);
}php:
Code: Select all
function MemberName($id)
{
$name=Sql :: Get($tblName, "WHERE id=$id");
return $name['member_name'];
}In the Sql class,
php:
Code: Select all
function Get($tblName, $cond)
{
$query=mysql_query("SELECT * FROM $tblName WHERE $cond");
return mysql_fetch_row($query);
}