Download the PHP package tegansnyder/idiorm-datatable-json-bridge without Composer

On this page you can find all versions of the php package tegansnyder/idiorm-datatable-json-bridge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package idiorm-datatable-json-bridge

idiorm-datatable-json-bridge

A bridge between Idiorm ORM and the popular DataTables javascript library that aims to abstract some of the pain points in mapping your database data to the JSON data DataTables expects.

Working code example here: https://github.com/tegansnyder/idiorm-datatable-json-bridge-example


Installation

This package is best loaded using composer and supports PHP versions > 5.2. To install into your project, add these lines to your composer.json:


Usage

Using this library requires you to replace any instance of the ORM class with OrmDatatableBridge in cases where you wish to retrieve DataTables formated JSON. It also requires you use get_datatable in place of find_many, find_one, or find_array when grabbing result sets.

Example:

Here is a very simple example showing you can use the same Idorim features you have before.

Returns:

Hidden DT Columns Example:

Hidden data and ID columns can be set to access the data in JQuery later. Reference: http://datatables.net/manual/server-side#Returned-data

Returns:

Advanced Example:

If you are like me you will find yourself needing to wrap columns of data in custom html. You might also want to add some dynamic columns and add buttons to your datatables for editing a row or removing a row. Below is an example of some advanced options you can pass the get_datatable method.

Returns:

Additional Options:

Many times the columns from your result set you may not want to actually use on your frontend. You can elect to hide these columns from the JSON output. In the backend database query they can still be selected, and used in templating, but just not included as a column in the JSON output. Here is an example:

Note in the above example I included a parameter called hide_column and set a value to id. I can still template off this value (example below):

Getting Column Names

If you want to grab a list of the column names to be used in marking up the HTML head of your table you can do another query to obtaining them by issuing the just_columns parameter. Note you can still supply the hide_columns parameter.

Renaming Column Names

If you find yourself auto populating the HTML table head by grabbing a list of the column names from the above query, you may also want to rename some of the column names for display purposes. For instance you may have a column in the database called store_price that you want to look like Store Price on the table head. To do this see the example below:

Reordering Columns

If you need to reorder the output of a select statement you can by using the column_order option. Please note if you have previously used the column_display_names option to rename columns you must use the new names when reordering. Example of reordering below:

Record Count:

In order to supply Datatables with the appropriate record count it needs to calculate the pagination this library includes some options for controling the record used for obtaining a count. To obtain this count it overrides the Idiorm _build_select method and does an intial COUNT query by wrapping your provided query in a SELECT COUNT(*) statement and removing any imposed LIMITS and OFFSETS from your query to get the full record count. It then uses this result to populate the recordsTotal portion of the JSON. I couldn't think a better way to do this, but I'm open to suggestions. For idorim raw queries this library expects you to name the query paramater bindings you pass to the raw_query method as 'LIMIT :limit' and 'OFFSET :offset' respectively.


Contributing

I'm happy to accept PR's that add additional functionality and fix bugs. I will do my best evaluate them prior to merging. The license is released under a BSD license similar to Idiorm.


Links

DataTables

Idorim

Thanks to all the contributors of both projects!


All versions of idiorm-datatable-json-bridge with dependencies

PHP Build Version
Package Version
Requires php Version >=5.2.0
j4mie/idiorm Version 1.5.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tegansnyder/idiorm-datatable-json-bridge contains the following files

Loading the files please wait ....