开发者

CodeIgniter Join/Overset Issue

开发者 https://www.devze.com 2023-04-12 15:50 出处:网络
I\'m using CodeIgniter to access my Mysql database and I have two tables (News and Events) with the column ID. I figured I could use a select before (also tried after) using the \'as\' keyword to retu

I'm using CodeIgniter to access my Mysql database and I have two tables (News and Events) with the column ID. I figured I could use a select before (also tried after) using the 'as' keyword to return the News ID column as NewsID but it returns the NewsID and overwrites the ID colu开发者_如何学Cmn still. Below is some code to show an example.

$this->db->join('News', 'News.ID = Events.NID', 'left');
$this->db->where('Events.ID', $ID);
$this->db->get('Events');

//tried this before and after the join and added to the condition
$this->db->select('*, News.ID as NewsID');

Any Information or ideas would be extremely helpful.


Try using

select('Events.*, News.ID as NewsID') 
0

精彩评论

暂无评论...
验证码 换一张
取 消