Good practices for a Model that interacts with 2 tables?

Asked

Viewed 36 times

1

I am building an MVC application, to be more exact for sending SMS messages, and I came across the following situation: I have the smsModel which is primarily responsible for sending, scheduling, cancelling the sending of SMS, and it has a standard table which are some information, for example, price per unit shipping, price for multiple sending and etc, basically all methods that interact with the database use this table, but there is a method responsible for saving a upload history and it uses another table, and would like to know if it is good practice to change the table name within the very method that makes that history or create a Model only for this purpose, the structure basically is this:

abstract class Model {

    protected function create (array $data) {

        $create_table = $this->table_name;
        //insere no banco
    }

}

class smsModel extends Model {

    private $table_name = 'sms_config';
    private $log_table_name = 'sms_log';

    public function create (array $data) {

        return parent::create($data);
    }

    public function create_sms_log (array $data) {
        $this->table_name = $this->log_table_name;
        return parent::create($data);

    }

}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.