CORE POS - IS4C
The CORE POS front end
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
BasicModel Class Reference
Inheritance diagram for BasicModel:
AutoCouponsModel CapturedSignatureModel CCredMembershipsModel CCredProgramsModel CouponAppliedModel CouponCodesModel CustdataModel CustomReceiptModel CustPreferencesModel CustReceiptMessageModel DateRestrictModel DepartmentsModel DisableCouponModel DrawerOwnerModel DTransactionsModel EfsnetRequestModel EfsnetRequestModModel EfsnetResponseModel EfsnetTokensModel EmployeesModel GlobalValuesModel HouseCouponItemsModel HouseCouponsModel HouseVirtualCouponsModel MasterSuperDeptsModel MemberCardsModel MemChargeBalanceModel MemtypeModel ParametersModel PaycardTransactionsModel ProductsModel QuickLookupsModel ShrinkReasonsModel SpecialDeptMapModel SubDeptsModel TaxRatesModel TendersModel UnpaidArTodayModel ViewModel

Public Member Functions

 db ()
 
 preferredDB ()
 
 __construct ($con)
 
 create ()
 
 createIfNeeded ($db_name)
 
 load ()
 
 reset ()
 
 getColumns ()
 
 getName ()
 
 find ($sort='', $reverse=false)
 
 delete ()
 
 save ()
 
 normalize ($db_name, $mode=BasicModel::NORMALIZE_MODE_CHECK, $doCreate=False)
 
 generate ($filename)
 
 newModel ($name)
 
 getModels ()
 

Public Attributes

const NORMALIZE_MODE_CHECK = 1
 
const NORMALIZE_MODE_APPLY = 2
 

Protected Member Functions

 getMeta ($type, $dbms)
 
 insertRecord ()
 
 updateRecord ()
 

Protected Attributes

 $name
 
 $columns = array()
 
 $unique = array()
 
 $meta_types
 
 $connection = false
 
 $instance = array()
 
 $preferred_db = ''
 

Constructor & Destructor Documentation

BasicModel::__construct (   $con)

Constructor

Parameters
$cona SQLManager object

Member Function Documentation

BasicModel::create ( )

Create the table

Returns
boolean
BasicModel::createIfNeeded (   $db_name)

Create structure only if it does not exist

Parameters
$db_name[string] database name
Returns
[keyed array] db => database name struct => table/view name error => [int] error code details => error details
BasicModel::delete ( )

Delete record from the database. Requires a uniqueness constraint. Assign those columns before calling delete().

Returns
boolean
BasicModel::find (   $sort = '',
  $reverse = false 
)

Find records that match this instance

Parameters
$sortarray of columns to sort by
Returns
an array of controller objects
BasicModel::generate (   $filename)

Rewrite the given file to create accessor functions for all of its columns

BasicModel::getMeta (   $type,
  $dbms 
)
protected

Get database-specific type

Parameters
$typea "meta-type" with different underlying type depending on the DB
$dbmsstring DB name
Returns
string
BasicModel::getModels ( )

Experiment using lambdas. I was curious if I could do recursion without having a named function.

BasicModel::insertRecord ( )
protected

Helper. Build & execute insert query

Returns
SQL result object or boolean false
BasicModel::load ( )

Populate instance with database values Requires a uniqueness constraint. Assign those columns before calling load().

Returns
boolean
BasicModel::normalize (   $db_name,
  $mode = BasicModel::NORMALIZE_MODE_CHECK,
  $doCreate = False 
)

Lane implementation lacks server methods: pushToLanes() deleteFromLanes() normalizeLanes() Compare existing table to definition Add any columns that are missing from the table structure Extra columns that are present in the table but not in the controlelr class are left as-is.

Parameters
$db_namename of the database containing the table
$modethe normalization mode. See above.
Returns
number of columns added or False on failure

Allow for db other than main ones, e.g. for a plugin. Force a new connection to avoid messing with the one maintained by the Database class

BasicModel::reset ( )

Clear object values.

BasicModel::save ( )

Save current record. If a uniqueness constraint is defined it will INSERT or UPDATE appropriately.

Returns
SQL result object or boolean false
BasicModel::updateRecord ( )
protected

Helper. Build & execute update query

Returns
SQL result object or boolean false

Member Data Documentation

BasicModel::$columns = array()
protected

Definition of columns. Keyed by column name. Values should be arrays with keys for:

  • type (required)
  • default (null if omitted)
  • primary_key (optional, boolean)
  • index (optional, boolean)
  • increment (optional, boolean)
BasicModel::$connection = false
protected

Database connection

BasicModel::$instance = array()
protected

List of column names => values

BasicModel::$meta_types
protected
Initial value:
= array(
'MONEY' => array('default'=>'DECIMAL(10,2)','mssql'=>'MONEY')
)

Type transalations for different DB backends.

BasicModel::$name
protected

Name of the table

BasicModel::$preferred_db = ''
protected

Name of preferred database

BasicModel::$unique = array()
protected

List of columns that should be unique per record. Only necessary if the table has no primary key.

const BasicModel::NORMALIZE_MODE_APPLY = 2

apply changes

const BasicModel::NORMALIZE_MODE_CHECK = 1

check for potential changes


The documentation for this class was generated from the following file: