Structures_DataGrid_DataSource_PDO
[ class tree: Structures_DataGrid_DataSource_PDO ] [ index: Structures_DataGrid_DataSource_PDO ] [ all elements ]

Class: Structures_DataGrid_DataSource_PDO

Source Location: /Structures_DataGrid_DataSource_PDO-0.2.0/Structures/DataGrid/DataSource/PDO.php

Class Overview

Structures_DataGrid_DataSource_SQLQuery
   |
   --Structures_DataGrid_DataSource_PDO

PDO SQL Query Data Source Driver


Author(s):

Version:

  • $Revision$

Methods


Inherited Variables

Inherited Methods


Class Details

[line 93]
PDO SQL Query Data Source Driver

This class is a data source driver for PHP Data Objects

SUPPORTED OPTIONS:

  • dbc: (object) A PDO instance that will be used by this driver. Either this or the 'dsn' option is required.
  • dsn: (string) A PDO dsn string. The PDO connection will be established by this driver. Either this or the 'dbc' option is required.
  • username: (string) Username for the created PDO connection. Only needed in conjunction with 'dsn' option.
  • password: (string) Password for the crated PDO connection. Only needed in conjunction with 'dsn' option.
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().



[ Top ]


Method Detail

__construct (Constructor)   [line 101]

Structures_DataGrid_DataSource_PDO __construct( )

Constructor
  • Access: public

[ Top ]

_connect   [line 114]

mixed _connect( )

Connect to the database
  • Return: Instantiated databased object, PEAR_Error on failure
  • Access: protected

[ Top ]

_disconnect   [line 134]

void _disconnect( )

Disconnect from the database
  • Access: protected

[ Top ]

_getOne   [line 257]

mixed _getOne( string $query)

Fetches and returns a single value
  • Return: The fetched value, PEAR_Error on failure
  • Access: protected

Parameters:

string   $query   —  The query string

[ Top ]

_getRecords   [line 160]

mixed _getRecords( string $query, integer $limit, integer $offset)

Fetches and returns the records
  • Return: The fetched records, PEAR_Error on failure
  • Access: protected

Parameters:

string   $query   —  The (modified) query string
integer   $offset   —  Offset (starting from 0)
integer   $limit   —  Limit

[ Top ]

_getRecordsNum   [line 276]

mixed _getRecordsNum( string $query)

Calculates (and returns) the number of records by getting all records
  • Return: The numbers row records, PEAR_Error on failure
  • Access: protected

Parameters:

string   $query   —  The query string

[ Top ]

_isConnection   [line 146]

bool _isConnection( object $dbc)

Whether the parameter is a PDO object
  • Return: Whether the parameter is a PDO object
  • Access: protected

Parameters:

object   $dbc   —  PDO object

[ Top ]

_quoteIdentifier   [line 221]

string _quoteIdentifier( $field)

Returns a quoted identifier
  • Return: The quoted identifier
  • Access: protected

Parameters:

   $field   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:48:18 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.