Jump to content

OOP concept while creating model classes


josephjohn

Recommended Posts

Hi,

I need some assistance in the OOP concept. My next project is related to some thing like jobs and employers website . Here I have tables like

 

jobseeker - jobseekername, jobseekeremail, jobseekeraddress, jobseekerphone ... etc and in employer table is like

 

employer - employername, employeremail, employeraddress, employermobile ... etc

 

Please provide us with the support that how to create model classes with these two tables.

Here I need to develop this project in a fully object orient manner.

 

Thanks,

Joseph

Link to comment
Share on other sites

Do you have an MVC framework that you are using??

 

you can easily create your own models depending on what you need.

below is a little sample of what you would want to do....

 

<?php
class Model{

public function user_info()
{
            //this is dummy information but it simulates info that you pull from the db
	return array(
		'id' => '1',
		'name' => 'John Doe',
	);
}


}
?>

Edited by jbwebdesign
Link to comment
Share on other sites

Thanks for the reply, currently I am using Zend MVC framework and I know how to use this, actually I don't need the code for the MVC , I need the idea of creating the structure of the model classes, for example how to use the inheritance usefully in this type of table structure etc.

 

 

 

Do you have an MVC framework that you are using??

 

you can easily create your own models depending on what you need.

below is a little sample of what you would want to do....

 

<?php
class Model{

public function user_info()
{
            //this is dummy information but it simulates info that you pull from the db
	return array(
		'id' => '1',
		'name' => 'John Doe',
	);
}


}
?>

Link to comment
Share on other sites

I might be confused with what your looking for, but you'll want to extend "Zend_Db_Table_Abstract" in your Models if your using Zend

 

<?php
class Jobseeker extends Zend_Db_Table_Abstract
{

//i create constants for my column names so if one is ever renamed, i can quickly rename every query with one change
const COL_ID = 'id';
const COL_JOBSEEKERNAME = jobseekername;


protected $_name = 'jobseeker'; // declare your table as is in your database

protected $_dependentTables = array(); //add your dependent tables to access to to them through this object / rowset

protected $_referenceMap = array(); //add your refernce map  Best to checkout Zend's documentation for what this and dependent Tables can do for you.

public function retrieveAll() {

[indent]return $this->fetchAll($this->select());[/indent]

}

public function retrieveOne($condition) { //in my example condition must be a int / product id to return anything

[indent]return $this->fetchRow($this->select()
->where(self::COL_ID = ?, $condition));[/indent]


}
}
?>

Hope this helps?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...