Skip to content
Murtnowski edited this page Dec 19, 2011 · 8 revisions

Ignited DataTables MySQL Helper is a library for Code Igniter to help you work with DataTables. It allows you to write your own MySQL query and then it modifies your query so that it adds the filter, sort by, and limit features of DataTables.

All you have to do is write a query that it will use that along with the DataTable’s $_POST variables to create a RecordSet you can turn into JSON later. It will also give you the iTotalRecords and iTotalDisplayRecords for your response.

I run this code in my model to execute my query.

     return $this->datatableshelper->query("SELECT a, b c, FROM myTable");

datatableshelper→query returns an array with an entry for sEcho, iTotalRecords, iTotalDisplayRecords, Result, and sColumns. Result is what can be used to create the aaData entry in the JSON to be returned. You have to use your own function to get this object ready to be encoded as JSON, but it’s pretty darn close already. I didn’t include my own JSON function because I usually like to make lots of custom edits to my data before encoding it.

See for how the JSON and aaData should be formatted.


Clone this wiki locally
You can’t perform that action at this time.