\Dewdrop\FieldsListing

The Listing class wraps a Select object and applies a number of SelectModifier objects to it, making it easy to sort, filter, etc. You can optionally specify a prefix for the Listing, which it will pass along to all its modifiers, allowing you to use multiple Listings on a single request without their GET and POST variables conflicting with one another.

Summary

Methods
Properties
Constants
__construct()
getPrimaryKey()
setPrefix()
getPrefix()
getRequest()
registerCustomModifier()
registerSelectModifier()
getSelectModifiers()
getSelectModifierByName()
getSelectSortModifier()
getSelectFilterModifier()
getSelectPaginateModifier()
hasSelectModifier()
removeSelectModifierByName()
getModifiedSelect()
fetchData()
fetchDataWithGenerator()
getTotalRowCount()
fetchRow()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$select
$prefix
$selectModifiers
$primaryKey
$totalRowCount
$request
N/A

Properties

$select

$select : \Dewdrop\Db\Select

The Select that will be used throughout this Listing.

Type

\Dewdrop\Db\Select

$prefix

$prefix : string

An optional prefix to use when reading/writing request parameters in this listing and its modifiers.

Type

string

$selectModifiers

$selectModifiers : array

An array of SelectModifier objects used to automatically modify the Select object.

Type

array

$primaryKey

$primaryKey : \Dewdrop\Db\Field

A field that can be used to look up single items in this listing's Select object.

Type

\Dewdrop\Db\Field

$totalRowCount

$totalRowCount : integer

The total number of rows that would have been fetched had no LIMIT clause been present on the Select object. This is calculated when you call fetchData(), assuming you have a SelectPaginate helper registered.

Type

integer

$request

$request : \Dewdrop\Request

The Request object used by this listing and its select modifiers.

Type

\Dewdrop\Request

Methods

__construct()

__construct(\Dewdrop\Db\Select  $select, \Dewdrop\Db\Field  $primaryKey, \Dewdrop\Request  $request = null) 

Supply the Select object that will be manipulated by this listing.

Parameters

\Dewdrop\Db\Select $select
\Dewdrop\Db\Field $primaryKey
\Dewdrop\Request $request

getPrimaryKey()

getPrimaryKey() : \Dewdrop\Db\Field

Retrieve this listing's primary key field. Sometimes useful when assembling URLs, etc.

Returns

\Dewdrop\Db\Field

setPrefix()

setPrefix(string  $prefix) : \Dewdrop\Fields\Listing

Set a prefix for this listing and any of its modifiers. This can aid in avoiding GET/POST variable naming conflicts when including multiple listings on a single page.

Parameters

string $prefix

Returns

\Dewdrop\Fields\Listing

getPrefix()

getPrefix() : string

Get the prefix that should be used for GET/POST params by this Listing and its modifiers.

Returns

string

getRequest()

getRequest() : \Dewdrop\Request

Return the request being used by this listing.

Returns

\Dewdrop\Request

registerCustomModifier()

registerCustomModifier(  $name, callable  $callback) : $this

Allow users to create a custom modifier that just uses a callback to modify the select object.

Parameters

$name
callable $callback

Returns

$this

registerSelectModifier()

registerSelectModifier(\Dewdrop\Fields\Helper\SelectModifierInterface  $selectModifier) : \Dewdrop\Fields\Listing

Register a new SelectModifierInterface object with this listing. Each modifier will get the opportunity to alter the Select prior to its being run.

Parameters

\Dewdrop\Fields\Helper\SelectModifierInterface $selectModifier

Returns

\Dewdrop\Fields\Listing

getSelectModifiers()

getSelectModifiers() : array

Get all the select modifiers that have been registered with this Listing.

Mostly useful during testing.

Returns

array

getSelectModifierByName()

getSelectModifierByName(string  $name) : \Dewdrop\Fields\Helper\SelectModifierInterface|false

Retrieve a select modifier using its name.

Parameters

string $name

Returns

\Dewdrop\Fields\Helper\SelectModifierInterface|false

hasSelectModifier()

hasSelectModifier(string  $name) : boolean

Check to see if this listing has a select modifier with the given name.

Parameters

string $name

Returns

boolean

removeSelectModifierByName()

removeSelectModifierByName(string  $name) : $this

Remove the select modifier that matches the supplied name.

Parameters

string $name

Returns

$this

getModifiedSelect()

getModifiedSelect(\Dewdrop\Fields  $fields) : \Dewdrop\Db\Select

Get the Select object after all modifiers have been applied to it. This can be useful if you'd like to see the Select (or its resulting SQL code) will all modifications applied, in case you need to debug or troubleshoot the code.

Parameters

\Dewdrop\Fields $fields

Returns

\Dewdrop\Db\Select

fetchData()

fetchData(\Dewdrop\Fields  $fields) : array

Fetch the data for this listing, passing the supplied \Dewdrop\Fields object to all modifiers before fetching the data from the DB.

Parameters

\Dewdrop\Fields $fields

Throws

Returns

array

fetchDataWithGenerator()

fetchDataWithGenerator(\Dewdrop\Fields  $fields) : \Generator

Fetch the data for this listing, passing the supplied \Dewdrop\Fields object to all modifiers before fetching the data from the DB using a PHP generator.

Parameters

\Dewdrop\Fields $fields

Returns

\Generator

getTotalRowCount()

getTotalRowCount() : integer

Return the total row count that would have been retrieved during fetchData() if no LIMIT clause was applied to the Select. Note that this will only work if you have a SelectPaginate select modifier registered with this listing.

Returns

integer

fetchRow()

fetchRow(\Dewdrop\Fields  $fields, mixed  $id) : \Dewdrop\Db\Row

Fetch a single row from this listing by using the supplied ID value to match against the listing's primary key field.

Parameters

\Dewdrop\Fields $fields
mixed $id

Returns

\Dewdrop\Db\Row