Structures_DataGrid_DataSource_PDO

Structures_DataGrid_DataSource_PDO – PDO SQL Query Data Source Driver

Description

This class is a data source driver for PHP Data Objects

Supported operations modes

This driver supports the following operation modes:

Supported operations modes of this driver
Mode Supported?
Multiple field sorting yes
Insert, update and delete records no

Options

This driver accepts the following options:

Options for this driver
Option Type Description Default Value
count_query string Query that calculates the number of rows. See below for more information about when such a count query is needed. ''
db_options array Options for the created database object. This option is only used when the 'dsn' option is given. array()
dbc object A PDO instance that will be used by this driver. Either this or the 'dsn' option is required. null
dsn string A PDO dsn string. The PDO connection will be established by this driver. Either this or the 'dbc' option is required. null
fields array Which data fields to fetch from the datasource. An empty array means: all fields. Form: array(field1, field2, ...) array()
generate_columns bool Generate Structures_DataGrid_Column objects with labels. See the 'labels' option. DEPRECATED: use Structures_DataGrid::generateColumns() instead false
labels array Data field to column label mapping. Only used when 'generate_columns' is true. Form: array(field => label, ...) DEPRECATED: use Structures_DataGrid::generateColumns() instead array()
password string Password for the crated PDO connection. Only needed in conjunction with 'dsn' option. null
primaryKey array Name(s), or numerical index(es) of the field(s) which contain a unique record identifier (only use several fields in case of a multiple-fields primary key) null
username string Username for the created PDO connection. Only needed in conjunction with 'dsn' option. null

General notes

You need to specify either a PDO instance or a PDO compatible dsn string as an option to use this driver.

If you use complex queries (e.g. with complex joins or with aliases), $datagrid->getRecordCount() might return a wrong result. For the case of GROUP BY, UNION, or DISTINCT in your queries, and for the case of subqueries, this driver already has special handling. However, if you observe wrong record counts, you need to specify a special query that returns only the number of records (e.g. 'SELECT COUNT(*) FROM ...') as an additional option 'count_query' to the bind() call.

You can specify an ORDER BY statement in your query. Please be aware that this sorting statement is then used in *every* query before the sorting options that come from a renderer (e.g. by clicking on the column header when using the HTML_Table renderer which is sent in the HTTP request). If you want to give a default sorting statement that is only used if there is no sorting query in the HTTP request, then use $datagrid->setDefaultSort().

PEAR::MDB2 SQL Query Data Source Driver (Previous) RSS data source driver (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.