• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Double select in builder

#1
For a database query im joining 2 tables. I want to add a second select since both tables have an id column. What i want:

Codeigniter 2:
PHP Code:
$this->db->select("*");
$this->db->select("main_table.id AS id");
$this->db->join("second_table","main_table.id = second_table.base_id","INNER");
$query $this->db->get("main_table"); 

Codeigniter 4:
PHP Code:
$db = \Config\Database::connect();
$builder $db->table('main_table');
$builder->select("*");
$builder->select("main_table.id AS id");
$builder->join("second_table","main_table.id = second_table.base_id","INNER");
$query $builder->get(); 


But in Codeigniter 4 this doesnt seem to work $query->getResult() returns just the id column.

Any ideas?
Reply


Messages In This Thread
Double select in builder - by RuudTableaux - 03-06-2020, 07:30 AM
RE: Double select in builder - by donpwinston - 03-06-2020, 11:06 AM
RE: Double select in builder - by RuudTableaux - 03-13-2020, 02:07 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.