Codeigniter - Ignited-DataTables-MySQL-Helper

Codeigniter - Ignited-DataTables-MySQL-Helper

MurtnowskiMurtnowski Posts: 1Questions: 0Answers: 0
edited March 2012 in General
Link: https://github.com/Murtnowski/Ignited-DataTables-MySQL-Helper

I built a library to be used with DataTables server-side requests so that you can just write a query as a string and then have it run with the DataTables request variables getting applied automatically.

It is an alterative to the active record style queries built in Ignited-Datatables. See http://codeigniter.com/forums/viewthread/160896/ . I usually prefer not having to write my queries with Active Records.

You write your query then the library modifies it and runs it for you while accounting for which records to grab, the sorting, and searching. It will respond back with an array containing all the information needed to encode the JSON response.

Usage Example:

[code]
<?php
$this->load->library('DatatablesHelper');
return $this->datatableshelper->query("SELECT a, b c, FROM myTable");
?>
[/code]

This code above 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.
This discussion has been closed.