Overview

Namespaces

  • Sleepy
  • Module
    • Authentication
    • CSV
    • DB
    • FormBuilder
    • FSDB
    • IP2Country
    • Mailer
    • MobiDetect
    • Navigation
    • StaticCache
  • PHP

Classes

  • DB
  • Grid
  • Record
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Class Grid

Creates a grid view of a sql statement

Usage

$dbg = new \Module\DB\Grid('users', 'SELECT * FROM users');

  $dbg->exclude(array(
    'user_id',
    'password'
  ));

  $dbg->mapFields(array(
    'name' => 'user_id'
  ));

  $dbg->sortable(array(
    'name',
    'date'
  ));

  $dbg->show();

Changelog

Version 1.2

  • Added namespacing

Version 1.1

  • Added the date section to documentation

Dependencies

  • class.db.php
  • class.hooks.php
Namespace: Module\DB
License: http://opensource.org/licenses/MIT
Author: Jaime A. Rodriguez hi.i.am.jaime@gmail.com
Version: 1.2
Date: August 13, 2014
Located at rid/class.dbgrid.php
Methods summary
public
# __construct( string $name, string $sql )

Constructor

Constructor

Parameters

$name
Give our DBForm a name, used for hooks and id
$sql
What SQL to run?
public
# sortable( array $array )

What columns can be sorted?

What columns can be sorted?

Parameters

$array

fields that are sortable, used when rendering the table headers

public
# setQuerystring( string $query )

Sets the Querystring to pass into the sorting links in the th

Sets the Querystring to pass into the sorting links in the th

Parameters

$query
the querystring
public
# sort( string $column, boolean $asc = true )

Sorts the table data

Sorts the table data

Parameters

$column
The column to sort by
$asc
Sort ascending?
public
# exclude( array $array )

Which fields are excluded from the table

Which fields are excluded from the table

Parameters

$array
a list of fields
private boolean
# isExcluded( string $str )

Checks to see if a column has been excluded

Checks to see if a column has been excluded

Parameters

$str
a column

Returns

boolean
true if it has been excluded
public
# mapFields( array $array )

Maps IDs to fields for processing later

Maps IDs to fields for processing later

Parameters

$array
a list of fields => id that gets passed to the hooks
public integer
# numberOfPages( )

Returns how many pages of results we have

Returns how many pages of results we have

Returns

integer
The number of pages in our resultset
public
# show( )

Shows an editable form

Shows an editable form

Properties summary
protected $db

DB The DB object

DB The DB object

#
protected $name

string The name of our grid

string The name of our grid

#
protected $sql

string The SQL to run to make the grid

string The SQL to run to make the grid

#
protected string $sortBy

string The column to sort by

string The column to sort by

# ''
protected boolean $asc

string Ascending? or Descending?

string Ascending? or Descending?

# true
public integer $maxRecords

int How many records per page?

int How many records per page?

# 10
public integer $page

int Which page are we on?

int Which page are we on?

# 1
public $meta

object The meta data for the fields

object The meta data for the fields

#
protected $canSortby

array string fields that are sortable. Used when rendering column header links

array string fields that are sortable. Used when rendering column header links

#
protected $excluded

array string Which fields to exclude from the table

array string Which fields to exclude from the table

#
protected $map

array associative An array of fields => id that gets passed to the hooks

array associative An array of fields => id that gets passed to the hooks

#
protected $querystring

string Querystring to pass into the sorting links in the th

string Querystring to pass into the sorting links in the th

#
sleepyMUSTACHE v.0.8 API documentation generated by ApiGen