After successful installation, call the constructor similar to the following:
1 | $dg = new C_DataGrid("SELECT * FROM Orders", "orderNumber", "Orders"); |
The details of phpGrid constructor is explained below:
__constructor($sql, $sql_key=’id’, $sql_table=”, $db_connection=”)
- Parameter(s):
- $sql: SQL SELECT statement. This is the only SQL statement users needs to implement. The SELECT statement must include the primary key as one of the columns if not using the wildcard start(*) in SELECT statement.
This parameter can also be a local array (version 5.5+). See phpGrid local array data source usage example.
- $sql_key: The name of the primary key of the database table. The default value is “id”.
- $sql_table: Name of the database table used in the SQL statement. If not defined, the table name is automatically parsed from the SQL statementent.
- $db_connection: Optional. Since version 4.3, the 4th parameter was introduced and used to overwrite connection parameters in conf.php. It allows datagrid to reference to a difference data source on the fly. See Reference to Multiple Databases example for more information on this parameter. If you have only one database, you can safely ignore this parameter.
- $sql: SQL SELECT statement. This is the only SQL statement users needs to implement. The SELECT statement must include the primary key as one of the columns if not using the wildcard start(*) in SELECT statement.
- Description:
- This is our datagrid object constructor. Use this method to create the phpGrid object. Usually this is the first line in your code.
- Remark:
- Do not include WHERE clause in $sql. Instead, use set_query_filter method (version 4.2+) to set filter in your query.
- If not using the wildcard star(*), the SELECT statement MUST include the primary key as one of the columns.
- Example:
1 | $dg = new C_DataGrid("SELECT * FROM Orders", "orderNumber", 'Orders'); |


