Jump to content

Interfaces & Database Design


ignace

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.

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.