Question

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 included 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)?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top