开发者

Persisting the table name in codeigniter models

In my models I'm setting them up using constructors like the following

function Areas()
{
    parent::Model();
    $this->db->from("areas");
}

However, if a method of my model queries the database several times it looks like the FROM clause is only inclu开发者_如何转开发ded in the first query. Is there an easy way to persist the FROM for all queries run within my model (unless I manually override it)?


I would advise against this. It would lead to REALLY hard to smush bugs later on down the line. The problem, I'm guessing, has more to do with the name of the table changing? In which case, you can use a constant for each table and change the name in config.

If you just wanted to save a line of code, sometimes more lines is better. This is the case here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜