josephjohn Posted November 22, 2011 Report Share Posted November 22, 2011 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 Quote Link to comment Share on other sites More sharing options...
jbwebdesign Posted November 22, 2011 Report Share Posted November 22, 2011 (edited) 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 November 22, 2011 by jbwebdesign Quote Link to comment Share on other sites More sharing options...
josephjohn Posted November 23, 2011 Author Report Share Posted November 23, 2011 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', ); } } ?> Quote Link to comment Share on other sites More sharing options...
jstern Posted November 23, 2011 Report Share Posted November 23, 2011 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.