POT
POT
POT
Main menu

Download

Forum

SVN

Class: OTS_Base_List

Source Location: /classes/OTS_Base_List.php

Class OTS_Base_List

Class Overview

Implements interfaces:

  • IOTS_DAO
  • Iterator (internal interface)
  • Countable (internal interface)

Basic list class routines.

Basic list class routines. This class defines entire lists mechanism for classes that represents records set from OTServ database. All child classes only have to define init() method to set table info for queries.

Table on which list will operate has to contain integer "id" field and single row representing class has to support loading by this filed as key.

This class is mostly usefull when you create own extensions for POT code.

Located in /classes/OTS_Base_List.php [line 39]



		
				Author(s):
		
API Tags:
Property-write:  int $limit: Sets LIMIT clause.
Property-write:  int $offset: Sets OFFSET clause.
Property-write:  OTS_SQLFilter $filter: Sets filter for list SQL query.
Abstract:  

Information Tags:
Version:  0.1.5
Version:  0.0.5
Since:  0.0.5

Properties

Methods

[ Top ]
Descendants
Child Class Description
OTS_Players_List List of players.
OTS_Groups_List List of groups.
OTS_Accounts_List List of accounts.
OTS_Guilds_List List of guilds.
OTS_Bans_List List of all bans.
OTS_GuildRanks_List List of guild ranks.

[ Top ]
Property Summary
string   $class   Class of generated objects.
PDO   $db   Database connection.
array   $rows   Query results.
string   $table   Default table name for queries.

[ Top ]
Method Summary
static void   __set_state()   Magic PHP5 method.
OTS_Base_List   __construct()   Sets database connection handler.
int   count()   Returns number of rows on list in current criterium.
OTS_Base_DAO   current()   Returns current row.
string   getSQL()   Returns SQL query for SELECT.
void   init()   Sets list parameters.
mixed   key()   Current cursor position.
void   next()   Moves to next row.
void   orderBy()   Appends sorting rule.
string   prepareSQL()   Returns generic SQL query that can be adaptated by child classes.
void   resetOrder()   Clears ORDER BY clause.
void   rewind()   Select rows from database.
void   setFilter()   Sets filter on list.
void   setLimit()   Sets LIMIT clause.
void   setOffset()   Sets OFFSET clause.
bool   valid()   Checks if there are any rows left.
void   __set()   Magic PHP5 method.
array   __sleep()   Magic PHP5 method.
void   __wakeup()   Magic PHP5 method.

[ Top ]
Properties
string   $class [line 97]

Class of generated objects.

Class of generated objects.

API Tags:
Access:  protected

Information Tags:
Version:  0.0.5
Since:  0.0.5

[ Top ]
PDO   $db [line 47]

Database connection.

Database connection.

API Tags:
Access:  protected

Information Tags:
Version:  0.1.5
Version:  0.0.5
Since:  0.0.5

[ Top ]
array   $rows [line 83]

Query results.

Query results.

API Tags:
Access:  protected

Information Tags:
Version:  0.1.5
Version:  0.0.5
Since:  0.0.5

[ Top ]
string   $table [line 90]

Default table name for queries.

Default table name for queries.

API Tags:
Access:  protected

Information Tags:
Version:  0.0.5
Since:  0.0.5

[ Top ]
Methods
static method __set_state  [line 151]

  static void __set_state( array $properties  )

Magic PHP5 method.

Magic PHP5 method. Allows object importing from var_export().

Parameters:
array   $properties:  List of object properties.

API Tags:
Access:  public

Information Tags:
Version:  0.1.3
Version:  0.0.5
Since:  0.0.5

[ Top ]
Constructor __construct  [line 104]

  OTS_Base_List __construct( )

Sets database connection handler.

Sets database connection handler.


API Tags:
Access:  public

Information Tags:
Version:  0.1.0
Version:  0.0.5
Since:  0.0.5

Redefined in descendants as:

[ Top ]
count  [line 276]

  int count( )

Returns number of rows on list in current criterium.

Returns number of rows on list in current criterium.


API Tags:
Return:  Number of rows.
Access:  public

Information Tags:
Version:  0.1.5
Version:  0.0.5
Throws:  PDOException On PDO operation error.
Since:  0.0.5

Implementation of:
Countable::count

[ Top ]
current  [line 223]

  OTS_Base_DAO current( )

Returns current row.

Returns current row. Returns object of class which handle single row representation. Object is initialised with ID of current position in result cursor.


API Tags:
Return:  Current row.
Access:  public

Information Tags:
Version:  0.1.3
Version:  0.0.5
Since:  0.0.5

Implementation of:
Iterator::current

Redefined in descendants as:

[ Top ]
getSQL  [line 349]

  string getSQL( [bool $count = false]  )

Returns SQL query for SELECT.

Returns SQL query for SELECT.

Parameters:
bool   $count:  Shows if the SQL should be generated for COUNT() variant.

API Tags:
Return:  SQL query part.
Access:  protected

Information Tags:
Version:  0.1.5
Version:  0.0.5
Since:  0.0.5

Redefined in descendants as:

[ Top ]
init  [line 113]

  void init( )

Sets list parameters.

Sets list parameters.


API Tags:
Abstract:  
Access:  public

Information Tags:
Version:  0.0.5
Since:  0.0.5

Redefined in descendants as:

[ Top ]
key  [line 254]

  mixed key( )

Current cursor position.

Current cursor position.


API Tags:
Return:  Array key.
Access:  public

Information Tags:
Version:  0.0.5
Since:  0.0.5

Implementation of:
Iterator::key

[ Top ]
next  [line 244]

  void next( )

Moves to next row.

Moves to next row.


API Tags:
Access:  public

Information Tags:
Version:  0.0.5
Since:  0.0.5

Implementation of:
Iterator::next

[ Top ]
orderBy  [line 318]

  void orderBy( OTS_SQLField|string $field, [int $order = POT::ORDER_ASC]  )

Appends sorting rule.

Appends sorting rule. First parameter may be of type string, then it will be used as literal field name, or object of OTS_SQLField class, then it's representation will be used as qualiffied SQL identifier name.

Note: Since 0.0.7 version $field parameter can be instance of OTS_SQLField class.

Parameters:
OTS_SQLField|string   $field:  Field name.
int   $order:  Sorting order (ascending by default).

API Tags:
Access:  public

Information Tags:
Version:  0.0.7
Version:  0.0.5
Since:  0.0.5

[ Top ]
prepareSQL  [line 373]

  string prepareSQL( array $fields, [bool $count = false]  )

Returns generic SQL query that can be adaptated by child classes.

Returns generic SQL query that can be adaptated by child classes.

Parameters:
array   $fields:  Fields to be selected.
bool   $count:  Shows if the SQL should be generated for COUNT() variant.

API Tags:
Return:  SQL query.
Access:  protected

Information Tags:
Version:  0.1.5
Version:  0.0.5
Since:  0.0.5
Since:  0.1.5

[ Top ]
resetOrder  [line 298]

  void resetOrder( )

Clears ORDER BY clause.

Clears ORDER BY clause.


API Tags:
Access:  public

Information Tags:
Version:  0.0.5
Since:  0.0.5

[ Top ]
rewind  [line 236]

  void rewind( )

Select rows from database.

Select rows from database.


API Tags:
Access:  public

Information Tags:
Version:  0.0.5
Throws:  PDOException On PDO operation error.
Since:  0.0.5

Implementation of:
Iterator::rewind

Redefined in descendants as:

[ Top ]
setFilter  [line 290]

  void setFilter( [OTS_SQLFilter $filter = null]  )

Sets filter on list.

Sets filter on list. Call without argument to reset filter.

Parameters:
OTS_SQLFilter|null   $filter:  Filter for list.

API Tags:
Access:  public

Information Tags:
Version:  0.0.5
Since:  0.0.5

[ Top ]
setLimit  [line 180]

  void setLimit( [int|bool $limit = false]  )

Sets LIMIT clause.

Sets LIMIT clause. Reduces amount of seleced rows up to given number.

Parameters:
int|bool   $limit:  Limit for SELECT (false to reset).

API Tags:
Access:  public

Information Tags:
Version:  0.0.5
Since:  0.0.5

[ Top ]
setOffset  [line 201]

  void setOffset( [int|bool $offset = false]  )

Sets OFFSET clause.

Sets OFFSET clause. Moves starting rows of selected set to given position.

Parameters:
int|bool   $offset:  Offset for SELECT (false to reset).

API Tags:
Access:  public

Information Tags:
Version:  0.0.5
Since:  0.0.5

[ Top ]
valid  [line 264]

  bool valid( )

Checks if there are any rows left.

Checks if there are any rows left.


API Tags:
Return:  Does next row exist.
Access:  public

Information Tags:
Version:  0.0.5
Since:  0.0.5

Implementation of:
Iterator::valid

[ Top ]
__set  [line 443]

  void __set( string $name, mixed $value  )

Magic PHP5 method.

Magic PHP5 method.

Parameters:
string   $name:  Property name.
mixed   $value:  Property value.

API Tags:
Access:  public

Information Tags:
Version:  0.1.0
Version:  0.0.5
Throws:  OutOfBoundsException For non-supported properties.
Since:  0.1.0
Since:  0.0.5

[ Top ]
__sleep  [line 124]

  array __sleep( )

Magic PHP5 method.

Magic PHP5 method. Allows object serialisation.


API Tags:
Return:  List of properties that should be saved.
Access:  public

Information Tags:
Version:  0.0.5
Since:  0.0.5

[ Top ]
__wakeup  [line 136]

  void __wakeup( )

Magic PHP5 method.

Magic PHP5 method. Allows object unserialisation.


API Tags:
Access:  public

Information Tags:
Version:  0.0.5
Since:  0.0.5

[ Top ]