Overview

Classes

  • Ws_logged_inModel
  • Ws_permissionsModel
  • Ws_role_permModel
  • Ws_rolesModel
  • Ws_user_roleModel
  • Ws_userModel
  • WsAuth
  • WsauthController
  • WsChart
  • WsConfig
  • WsController
  • WsDatabase
  • WsForm
  • WsImage
  • WsLocalize
  • WsModel
  • WsModelForm
  • WsModelGridView
  • WsUrl

Functions

  • __autoload
  • callHook
  • WsErrorHandler
  • Overview
  • Class

Class WsModel

WsModel Is model part of Model-View-Controller. WsModel is the base class providing the common features needed by data model objects.

Example usage:

class TestModel extends WsModel
{
    public function __construct()
    {
        // autodetect columns, column types, etc
        parent::__construct();

        // change some column types
        // change column type for column
        $this->columnType['enter_date'] = 'date_type';
        // change column type for other column
        $this->columnType['is_checked'] = 'bool_type';
        // leave other column types unchanged (autodetected)
    }
}

// use model
$m = new TestModel();

// get one record with ID 100 from database
$m->getOne(100);
// show field value for retrived record
echo $m->name.'\n';

// change value of one column in record with ID 100
$m->name = 'New Name';
// save changes
$m->save();

// delete record with ID 100 from database
$m->id = 100;
$m->delete();
// same as above
$m->delete(100);
WsDatabase
Extended by WsModel

Direct known subclasses

Ws_logged_inModel, Ws_permissionsModel, Ws_role_permModel, Ws_rolesModel, Ws_user_roleModel, Ws_userModel
Located at WsModel.class.php
Methods summary
public
# __construct( )

Overrides

WsDatabase::__construct()
public
# setTableName( string $name )

Sets name of database table on which model references. Also updates all propertyes that hold informations about table columns: $column $columnCanBeNull $columnHeaders $foreignKeys $primaryKey

Sets name of database table on which model references. Also updates all propertyes that hold informations about table columns: $column $columnCanBeNull $columnHeaders $foreignKeys $primaryKey

Parameters

$name
Name of database table
public boolean
# idExists( integer $id )

Check if record, which primary key has value of parameter $id, exists in database.

Check if record, which primary key has value of parameter $id, exists in database.

Parameters

$id
Value of primary key

Returns

boolean
True if record exists or false if not.
public boolean
# beforeDelete( )

This method is invoked before deleting a record from database.

This method is invoked before deleting a record from database.

Returns

boolean
True on success or false otherwise
public boolean
# delete( )

Delete record from database.

Delete record from database.

Returns

boolean
True on success or false otherwise
public boolean
# beforeSave( )

This method is invoked before saving a record.

This method is invoked before saving a record.

Returns

boolean
True on success or false otherwise
public boolean
# save( )

Saves record to database. If primary_key column with specified value allready exists then perform update of record and if not then perform insert of new record.

Saves record to database. If primary_key column with specified value allready exists then perform update of record and if not then perform insert of new record.

Returns

boolean
True on success or false on error
public array
# getOne( integer $id,… )

Get one record from table.

Get one record from table.

Parameters

$id,…
Value of primary_key column which will be returned

Returns

array
$results if record is found or false
public array
# getAll( string $order = '', integer $limit = 0, integer $offset = 0 )

Gets all records from table

Gets all records from table

Parameters

$order
represents in which order result should be returned
$limit
limits number of results
$offset
starting record for return

Returns

array
$results if records exists or false
public array
# search( string $condition = '', string $order = '', integer $limit = 0, integer $offset = 0 )

Gets all records from model that satisfaid specific condition.

Gets all records from model that satisfaid specific condition.

Parameters

$condition
SQL condition
$order
represents in which order result should be returned
$limit
limits number of results
$offset
starting record for return

Returns

array
$results if records exists or false
public integer
# getNextId( )

Gets next ID value from model

Gets next ID value from model

Returns

integer
$next_id
Methods inherited from WsDatabase
__destruct(), close(), execute(), execute_batch(), query()
Properties summary
public string $className

$className Name of model

$className Name of model

# ''
public string $tableName

$tableName Name of database table

$tableName Name of database table

# ''
public string $metaName

$metaName Long name (description) of database table

$metaName Long name (description) of database table

See

WsModel::setTableName()
# ''
public array $columns

List of table columns. This list is automaticaly populated during the class initialization.

List of table columns. This list is automaticaly populated during the class initialization.

# array()
public string $primary_key

$primary_key Column that is primary key

$primary_key Column that is primary key

# 'id'
public array $columnCanBeNull

$columnCanBeNull List of columns that can store NULL values

$columnCanBeNull List of columns that can store NULL values

# array()
public array $columnType

$columnType List of column types

$columnType List of column types

# array()
public array $columnHeaders

$columnHeaders List of column headers

$columnHeaders List of column headers

See

WsModelForm
WsModelGridView
# array()
public array $foreignKeys

List of arrays wich represents relations between two WsModel classes. This list is automaticaly populated during the class initialization with regresion that display properti is referencing to foreign column name.

List of arrays wich represents relations between two WsModel classes. This list is automaticaly populated during the class initialization with regresion that display properti is referencing to foreign column name.

Usage:

$foreignKeys = array(
    'column_name' => array(
        'table' => 'foreign_table_name',
        'column' => 'foreign_column_name',
        'display' => 'foreign_column_that_would_be_used_for_display'
    )
);
# array()
public array $hiddenColumns

$hiddenColumns List of columns that are hidden from user

$hiddenColumns List of columns that are hidden from user

See

WsModelForm
WsModelGridView
# array()
Properties inherited from WsDatabase
$isConnected, $nRows
API documentation generated by ApiGen