A basic PHP datagrid requires only as little as TWO lines of code. First of all, always create a phpGrid object in the first line; then call its methods to define properties, and lastly always call display() to render to screen.
- parameter 1: SQL query
- parameter 2: SQL primary key
- parameter 3: SQL table name
Where to Obtain Demo Database
The demo database is available inside the folder “examples\SampleDB“. The file name suggests its associated database type. The following demo databases are included for your convenience: MySQL, MS SQL Server, DB2, SQLite, MS Access, Oracle, Postgres.
Please note in some databases, such as Firebird, MS Access, the fields name are case-sensitive. Make sure the name used in the code matches the case when you are using those type of databases.
DO NOT INCLUDE “WHERE” CLAUSE IN $sql. Instead use set_query_filter method (version 4.2+) to set query filter.
The third parameter is ALWAYS equals to the database table name, not an alias or any arbitrary name (see below).
SELECT * FROM `my-table` -- requires ` around table name
SELECT * FROM my_table -- does not require surrounding quotes.
“Fatal error: Class “C_DataGrid” not found in …”