I use Ignited Table and I would like to combine 2 filed results in one column.
$this->datatables
->select('ci_orders.id,'
.'ci_orders.transaction_id,'
.'ci_orders.field1,'
.'ci_orders.field2,'
.'ci_orders.status')
->from('ci_orders')
->join('ci_users', 'ci_orders.user = ci_users.id')
->where('ci_users.id',$userId)
->unset_column('ci_orders.id')
->add_column('edit', '<a href="' . base_url() . 'cancel_order/$1"><button class="btn btn-danger" type="button"><i class="fa fa-times-circle"></i> Cancel</button>', 'id');
with this query I would have a table like
---transaction_id---|---field_header1---|---field_header2---|---status---
some id | value1 | value2 | pending
What I would like to achieve
---transaction_id---|---field_header---|---status---
some id | value1/value2 | pending
is ignited table ablle to handle this?
While viewing the code at Ignited-Datatables / application / libraries / Datatables.php i found the select function of ignited tables it actually used codeigniter's active library so you can use the mysql's CONCAT(str1,str2,...) function
/* demo code just to show ,taken from ignited tables*/
public function select($columns, $backtick_protect = TRUE)
{
foreach($this->explode(',', $columns) as $val)
{
$column = trim(preg_replace('/(.*)\s+as\s+(\w*)/i', '$2', $val));
$this->columns[] = $column;
$this->select[$column] = trim(preg_replace('/(.*)\s+as\s+(\w*)/i', '$1', $val));
}
$this->ci->db->select($columns, $backtick_protect);
return $this;
}
you can try this one by adding second parameter $backtick_protect
as FALSE
$this->datatables
->select("ci_orders.id,ci_orders.transaction_id,
CONCAT(ci_orders.field1, ' ', ci_orders.field2) AS ci_orders.field1,
ci_orders.status",FALSE)
->from('ci_orders')
->join('ci_users', 'ci_orders.user = ci_users.id')
->where('ci_users.id',$userId)
->unset_column('ci_orders.id')
->add_column('edit', '<a href="' . base_url() . 'cancel_order/$1"><button class="btn btn-danger" type="button"><i class="fa fa-times-circle"></i> Cancel</button>', 'id');