![]() |
CI4 Alias not working - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: CI4 Alias not working (/showthread.php?tid=88423) |
CI4 Alias not working - Gumzy - 09-06-2023 Hi, I cannot get my alias to work so that I can join other tables rather than running multiple queries at once. PHP Code: error: Please see code below: PHP Code: $builder = $this->db->table($this->tables_alias['logs']) PHP Code: public array $tables_alias = [ RE: CI4 Alias not working - ozornick - 09-06-2023 It seems table() only takes the table name and adds a prefix. That's why you see the error. If so important, try removing the prefix for the query. Perhaps there is another option https://codeigniter4.github.io/userguide/database/queries.html#db-setprefix RE: CI4 Alias not working - JustJohnQ - 09-06-2023 I don’t see flare_l.id in any of your code? RE: CI4 Alias not working - ozornick - 09-06-2023 "flare_" prefix. He auto concat with table RE: CI4 Alias not working - JustJohnQ - 09-06-2023 Looks like I can’t see the code on my phone. Can’t really tell why a table alias is necessary to create a join. RE: CI4 Alias not working - kenjis - 09-06-2023 QueryBuilder's table name supports an alias. Quote:@param array|string $tableName tablename or tablenames with or without aliases See https://github.com/codeigniter4/CodeIgniter4/blob/be40bfb6230659cea93fd9a1c2ac181f7bb193df/system/Database/BaseBuilder.php#L295-L304 RE: CI4 Alias not working - Gumzy - 09-07-2023 (09-06-2023, 10:12 AM)ozornick Wrote: It seems table() only takes the table name and adds a prefix. Apperciate it. The prefix was causing the issue so I've just removed it. |