Welcome Guest, Not a member yet? Register   Sign In
Table short name and queries

(11-09-2022, 12:37 AM)kenjis Wrote: I found tips to get QueryBuilder from the Model:

Ok, that seems to "fix" the issue. going back to my simple example and adding "->from()", instead of ->table() seems to take care of the issue:

PHP Code:
$records $this->newsModel 
->select('n.id, title, n.created_at, n.is_active, u.firstname')
    ->from('news n'true)
    ->join('users u','n.createdby_id = u.id','left')
    ->orderBy('n.is_active DESC, n.title ASC')

However, I note that the example given in that thread adds a second parameter to the ->from() of TRUE. I can't find anything in the docs as to what that TRUE does (suspect it allows for table override).

See https://codeigniter4.github.io/CodeIgnit...lder::from

(11-10-2022, 06:42 PM)kenjis Wrote: See https://codeigniter4.github.io/CodeIgnit...lder::from

Thanks. Not sure how I managed to miss that! LOL

Theme © iAndrew 2016 - Forum software by © MyBB