Class miModelSQLRecordset

Description

Handle and manage the reading of data from database.

This class only read data from a given database table with necessary ordering and filtering.

  • copyright: Mirchev Ideas Ltd. © 2003, 2004

Located in /model/SQLRecordset.inc (line 25)


	
			
Method Summary
 miModelSQLRecordset miModelSQLRecordset (string $table)
 void addFilter (array $arrayFilter)
 void addHiddenFilter (array $arrayFilter)
 void getFields ()
 array getRecords ()
 array getRecordsByIndex (int $fromIndex, int $numRecords)
 string getSqlOrderClause ()
 void setOrder (string $sortBy, string $sortDir)
 void setRecordsLimit (int $from, int $num)
Methods
Constructor miModelSQLRecordset (line 94)

miModelSQLRecordset constructor. It takes one parameter - table name

Example:


1 <?php
2 $ModelSQLRecordset = new miModelSQLRecordset('tableName');
3 ?>

  • access: public
miModelSQLRecordset miModelSQLRecordset (string $table)
  • string $table: database table name
addFilter (line 138)

Sets an array that hold the all filter parameters for the execution of the query.

Example:


1 <?php
2 $ModelSQLRecordset = new miModelSQLRecordset('tableName');
3 $ModelSQLRecordset->addFilter($arrayFilter);
4 ?>

  • access: public
void addFilter (array $arrayFilter)
  • array $arrayFilter: array with specified filter clauses
addHiddenFilter (line 158)

Sets an array that hold the hidden filter parameters for the execution of the query.

Example:


1 <?php
2 $ModelSQLRecordset = new miModelSQLRecordset('tableName');
3 $ModelSQLRecordset->addHiddenFilter($arrayFilter);
4 ?>

  • access: public
void addHiddenFilter (array $arrayFilter)
  • array $arrayFilter: array with specified filter clauses
getFields (line 235)
void getFields ()
getRecords (line 203)

Read rows from a database table.

The result reply to the given filter clause and is returned in order specify by order clause

Example:


1 <?php
2 $ModelSQLRecordset = new miModelSQLRecordset('tableName');
3 $ModelSQLRecordset->setOrder($tableField, 'ASC');
4 $ModelSQLRecordset->addFilter($arrayFilter);
5 $rows = $ModelSQLRecordset->getRecords();
6 ?>

  • return: rows returned from database
  • access: public
array getRecords ()
getRecordsByIndex (line 344)

Read fixed number of rows from a given index in a database table.

The result reply to the given filter clause and is returned in order specify by order clause

Example:


1 <?php
2 $ModelSQLRecordset = new miModelSQLRecordset('tableName');
3 $ModelSQLRecordset->setOrder($tableField, 'ASC');
4 $ModelSQLRecordset->addFilter($arrayFilter);
5 $rows = $ModelSQLRecordset->getRecordsByIndex($fromIndex, $numRecords);
6 ?>

  • return: rows returned from database
  • access: public
array getRecordsByIndex (int $fromIndex, int $numRecords)
  • int $fromIndex: from which record index to start
  • int $numRecords: number of rows to be read
getRecordsCount (line 308)

Return the number of all rows in a database table that reply to the given filter clause

Example:


1 <?php
2 $ModelSQLRecordset = new miModelSQLRecordset('tableName');
3 $ModelSQLRecordset->addFilter($arrayFilter);
4 $count = $ModelSQLRecordset->getRecordsCount();
5 ?>

  • return: number of all rows in a database table
  • access: public
int getRecordsCount ()
getSqlOrderClause (line 224)

Return the order clause

Example:


1 <?php
2 $ModelSQLRecordset = new miModelSQLRecordset('tableName');
3 $ModelSQLRecordset->setOrder($tableField, 'ASC');
4 $order = $ModelSQLRecordset->getSqlOrderClause();
5 ?>

  • return: order clause
  • access: public
string getSqlOrderClause ()
setOrder (line 116)

Sets the field by which the result of the query will be ordered and the direction of ordering - ascending or descending.

Example:


1 <?php
2 $ModelSQLRecordset = new miModelSQLRecordset('tableName');
3 $ModelSQLRecordset->setOrder($tableField, 'ASC');
4 ?>

  • access: public
void setOrder (string $sortBy, string $sortDir)
  • string $sortBy: database table field name
  • string $sortDir: direction of ordering - ascending or descending
setRecordsLimit (line 178)

Sets how many rows to be read from the databse

Example:


1 <?php
2 $ModelSQLRecordset = new miModelSQLRecordset('tableName');
3 $ModelSQLRecordset->setRecordsLimit(5, 20);
4 ?>

  • access: public
void setRecordsLimit (int $from, int $num)
  • int $from: from which record index to start
  • int $num: how many rows to read

Documentation generated on Mon, 18 Oct 2004 14:58:32 +0300 by phpDocumentor 1.2.3