Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/193573-interfaces-database-design/
Share on other sites

  • 2 weeks later...

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.

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.