[eluser]webmarkcompt[/eluser]
Hello everyone
It's possible to concat two values inside this select function?
Such as categories.name as cname and subcategories.name as subcategory ?
Code: function getdatatableajaxcost()
{
$this->load->library('datatables');
$this->datatables
->select("
products.id as productid,
products.image as image,
products.code as code,
categories.name as cname,
subcategories.name as subcategory,
products.cost,
products.price,
products.details", FALSE)
->from('products')
->join('categories', 'products.category_id=categories.id', 'left')
->join('subcategories', 'products.subcategory_id=subcategories.id', 'left')
->group_by("products.id");
The idea is retrieve both values on the same column inside a jquery datatable.
Any sugestion?
[eluser]larsonator[/eluser]
Should be, just put it in your select statement.
The Active record essentially a query builder,
try something like this:
Code: function getdatatableajaxcost()
{
$this->load->library('datatables');
$this->datatables
->select("
products.id as productid,
products.image as image,
products.code as code,
CONCAT(categories.name, ' ', subcategories.name) as catcombined,
categories.name as cname,
subcategories.name as subcategory,
products.cost,
products.price,
products.details", FALSE)
->from('products')
->join('categories', 'products.category_id=categories.id', 'left')
->join('subcategories', 'products.subcategory_id=subcategories.id', 'left')
->group_by("products.id");
[eluser]webmarkcompt[/eluser]
[quote author="larsonator" date="1412721324"]Should be, just put it in your select statement.
The Active record essentially a query builder,
try something like this:
Code: function getdatatableajaxcost()
{
$this->load->library('datatables');
$this->datatables
->select("
products.id as productid,
products.image as image,
products.code as code,
CONCAT(categories.name, ' ', subcategories.name) as catcombined,
categories.name as cname,
subcategories.name as subcategory,
products.cost,
products.price,
products.details", FALSE)
->from('products')
->join('categories', 'products.category_id=categories.id', 'left')
->join('subcategories', 'products.subcategory_id=subcategories.id', 'left')
->group_by("products.id");
[/quote]
It worked like a charm!
A big thanks!
|