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

(11-09-2022, 12:37 AM)kenjis Wrote: I found tips to get QueryBuilder from the Model:
https://github.com/codeigniter4/CodeIgni...-869103637

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')
    ->findAll(); 

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).
Reply


Messages In This Thread
Table short name and queries - by SoccerGuy3 - 11-07-2022, 04:37 PM
RE: Table short name and queries - by kenjis - 11-07-2022, 04:53 PM
RE: Table short name and queries - by SoccerGuy3 - 11-07-2022, 05:36 PM
RE: Table short name and queries - by kenjis - 11-07-2022, 06:00 PM
RE: Table short name and queries - by SoccerGuy3 - 11-08-2022, 09:49 AM
RE: Table short name and queries - by kenjis - 11-08-2022, 04:46 PM
RE: Table short name and queries - by SoccerGuy3 - 11-08-2022, 04:50 PM
RE: Table short name and queries - by davis.lasis - 11-09-2022, 12:30 AM
RE: Table short name and queries - by SoccerGuy3 - 11-09-2022, 05:25 PM
RE: Table short name and queries - by kenjis - 11-09-2022, 12:37 AM
RE: Table short name and queries - by SoccerGuy3 - 11-10-2022, 08:56 AM
RE: Table short name and queries - by kenjis - 11-10-2022, 06:42 PM
RE: Table short name and queries - by SoccerGuy3 - 11-11-2022, 07:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB