ignace Posted February 27, 2010 Share Posted February 27, 2010 Hi assume I have a database table structure like: create table group ( id integer not null auto_increment, owner_email integer, short_name varchar(32), long_name varchar(64), key group_owner_email_idx (owner_email), primary key (id)); And an interface like: interface GTM_Group_Interface { public function getId(); public function setId($id); public function getOwner(); public function setOwner(GTM_Subscriber_Interface $subscriber); public function getShortName(); public function setShortName($shortName); public function getLongName(); public function setLongName($longName); public function getSubscribers(); public function setSubscribers($subscribers); public function addSubscribers($subscribers); } Is this correct? Or am I doing it wrong? Quote Link to comment https://forums.phpfreaks.com/topic/193573-interfaces-database-design/ Share on other sites More sharing options...
freakstyle Posted March 12, 2010 Share Posted March 12, 2010 HI There, what is it that you are trying to do with your interface? A database table doesn't have anything to do with that interface as you have it noted, so i'm not sure what your looking for. your method setOwner should not be asking if $subscriber is the interface, you can't instantiate an interface you can only implement one. I don't know if your class was more of an example or not, but it would be cleaner to use php's magic methods __get, __set, etc.. You can still define these in your interface, it just looks like you have methods defined that do pretty much the same thing, just dealing with different data. Quote Link to comment https://forums.phpfreaks.com/topic/193573-interfaces-database-design/#findComment-1025404 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.