在特定的json中获取mysql结果

时间:2016-03-05 08:54:27

标签: php mysql json codeigniter datatables

我的项目有问题。
我正在使用Codeigniter及其REST库,Datatables jquery插件

我的桌子

ID  TABLE NAME  WAITER NAME DATE AND TIME       FOODS         STATUS    TOTAL
1   Table 1     Waiter 1    1016-03-03 12:44:24 Chicken Fry-2 Pending   1500
                                                Beef       -2

我的梦想数据表

$this->db->select('orderitems.*, order.*');
$this->db->from('order');
$this->db->from('orderitems');
$data = $this->db->get()->result_array();
$this->response($data);

我当前的查询

[
  {
    "id": "1",
    "order_id": "1",
    "food_item": "Chicken Fry",
    "item_qty": "2",
    "table_id": "Table 1",
    "waiter_name": "Waiter 1",
    "date_time": "2016-03-03 12:44:27",
    "status": "Pending",
    "total": "1500"
  },
  {
    "id": "1",
    "order_id": "1",
    "food_item": "Beef",
    "item_qty": "2",
    "table_id": "Table 1",
    "waiter_name": "Waiter 1",
    "date_time": "2016-03-03 12:44:27",
    "status": "Pending",
    "total": "1500"
  }
]

和json

LOAD CSV... row
MERGE (n) WHERE n.Name = row.id
SET n.{row.p} = row.v

如何使用json和datatable获取此数据表?
codeigniter查询生成器或mysql查询。

1 个答案:

答案 0 :(得分:0)

将数组返回给json对象。 json_decode或json_encode 对不起,但你的问题可能不太清楚。