1
votes

I want to get custom column with custom value with each row selection of table using codeigniter active record. In normal MySql selection query i can do that, but using active record custom column is unknown. SO how to do that? for any help thanks.

$this->db->select('name,\'custom_col\'')->from('my_table')->get();
2

2 Answers

1
votes

You can do like this:

$this->db->select("'custom_col',name",FALSE)->from('my_table')->get();
1
votes
$this->db->select('title, content, date');    
$query = $this->db->get('mytable');

You can also do like this

$this->db->select('(SELECT SUM(payments.amount) FROM payments WHERE payments.invoice_id=4') AS amount_paid', FALSE); 
$query = $this->db->get('mytable');

Check this link https://ellislab.com/codeigniter/user-guide/database/active_record.html#select