Documentation home page

cfrails
Component Model

Model

The base Model class, from which all models should be derived.

Method Summary
public any init([struct params="#structNew()#"])
          returns the properly instantiated derivative of Model
public any addValidation([any code], [any message])
          Adds a validation to be performed before a save is committed.
public any after_insert()
          Executed before the after_save() method, and after the insert. It is executed after successfully passing validation and of course, after the insert. It is not executed if validation failed.
public any after_save()
          Executed after the save, and after the after_insert() or after_update() methods. It is executed after successfully passing validation and of course, after the update or insert. It is not executed if validation failed.
public any after_update()
          Executed before the after_save() method, and after the update. It is executed after successfully passing validation and of course, after the update. It is not executed if validation failed.
public any afterInsert()
          Alias for after_insert().
public any afterSave()
          Alias for after_save().
public any afterUpdate()
          Alias for after_update()..
public any autoload_relationship(any columns, any table, any joinOn, [any joinType="inner"])
public any before_insert()
          Executed after the before_save() method, and before the insert. It is also executed before any validation takes place, in case something is needed to pass validation.
public any before_save()
          Executed before the save, and before the before_insert() or before_update() methods. It is also executed before any validation takes place, in case something is needed to pass validation.
public any before_update()
          Executed after the before_save() method, and before the update. It is also executed before any validation takes place, in case something is needed to pass validation.
public any beforeInsert()
          Alias for before_insert().
public any beforeSave()
          Alias for before_save().
public any beforeUpdate()
          Alias for before_update()..
public any destroy()
          Deletes the record for the model's current ID.
public any do_delete()
          Alias for destroy().
public any do_insert()
          Alias for doInsert().
public any do_update()
          Alias for doUpdate().
public any doDelete()
          Alias for destroy().
public any doInsert()
          Inserts the model's current field values into the model's table. Returns a blank string upon success, or a · (alt-250) delimited list of errors otherwise.
public any doUpdate()
          Updates the model's record in the table with the model's current field values, assuming the id is valid. Returns a blank string upon success, or a · (alt-250) delimited list of errors otherwise.
public any exec_query(any sqlQueryText)
          Alias for execute_query.
public any execQuery(any sqlQueryText)
          Alias for exec_query.
public any execute_query(any sqlQueryText)
          As a convenience only, you can just send a sql statement here and it will be executed.
public any executeQuery(any sqlQueryText)
          Alias for exec_query.
public any find_all([any orderBy=""], [any filter])
          Finds all records of the model's type
public any find_by_id(any id)
          Finds a record of this type given its ID.
public any findAll([any orderBy=""])
          Alias for find_all
public any findByID(any id)
          Alias for find_by_id
public any get_columns_properties([string whichColumn=""])
          Alias for getColumnsProperties().
public string get_human_name(string columnName)
public any get_table_name()
          Alias for getTableName().
public any getColumnsProperties([string whichColumn=""])
          Returns a query containing the model's columns properties: name, type, is_nullable, max_length, default_value, and priority. The records returned are sorted in order of priority, ascending.
public any getPrimaryKey()
public any getTableName()
public any save()
          If the id is set, updates the table with the values in the fields. Otherwise, it inserts them.
public any set_human_name(string columnName, string humanName)
          Sets the human name of a column.
public any set_priority(string columnName, numeric priority)
          Sets the priority of a column. Also increases each priority coming 'after' the value passed by one, to break any ties. In effect, this method 'inserts' the column into row specified.
public any setPrimaryKey([any pkname])
 

Method Detail

addValidation

public any addValidation([any code], [any message])
Adds a validation to be performed before a save is committed.

Parameters:
[any code] - The name of a function to run that performs the validation. The function return a true if the validation passed, or false if it failed.
[any message] - A message to display upon failing the validation.

after_insert

public any after_insert()
Executed before the after_save() method, and after the insert. It is executed after successfully passing validation and of course, after the insert. It is not executed if validation failed.


after_save

public any after_save()
Executed after the save, and after the after_insert() or after_update() methods. It is executed after successfully passing validation and of course, after the update or insert. It is not executed if validation failed.


after_update

public any after_update()
Executed before the after_save() method, and after the update. It is executed after successfully passing validation and of course, after the update. It is not executed if validation failed.


afterInsert

public any afterInsert()
Alias for after_insert().


afterSave

public any afterSave()
Alias for after_save().


afterUpdate

public any afterUpdate()
Alias for after_update()..


autoload_relationship

public any autoload_relationship(any columns, any table, any joinOn, [any joinType="inner"])
Parameters:
any columns
any table
any joinOn
[any joinType="inner"]

before_insert

public any before_insert()
Executed after the before_save() method, and before the insert. It is also executed before any validation takes place, in case something is needed to pass validation.


before_save

public any before_save()
Executed before the save, and before the before_insert() or before_update() methods. It is also executed before any validation takes place, in case something is needed to pass validation.


before_update

public any before_update()
Executed after the before_save() method, and before the update. It is also executed before any validation takes place, in case something is needed to pass validation.


beforeInsert

public any beforeInsert()
Alias for before_insert().


beforeSave

public any beforeSave()
Alias for before_save().


beforeUpdate

public any beforeUpdate()
Alias for before_update()..


destroy

public any destroy()
Deletes the record for the model's current ID.


do_delete

public any do_delete()
Alias for destroy().


do_insert

public any do_insert()
Alias for doInsert().


do_update

public any do_update()
Alias for doUpdate().


doDelete

public any doDelete()
Alias for destroy().


doInsert

public any doInsert()
Inserts the model's current field values into the model's table. Returns a blank string upon success, or a · (alt-250) delimited list of errors otherwise.


doUpdate

public any doUpdate()
Updates the model's record in the table with the model's current field values, assuming the id is valid. Returns a blank string upon success, or a · (alt-250) delimited list of errors otherwise.


exec_query

public any exec_query(any sqlQueryText)
Alias for execute_query.

Parameters:
any sqlQueryText - Any legal SQL statement

execQuery

public any execQuery(any sqlQueryText)
Alias for exec_query.

Parameters:
any sqlQueryText - Any legal SQL statement

execute_query

public any execute_query(any sqlQueryText)
As a convenience only, you can just send a sql statement here and it will be executed.

Parameters:
any sqlQueryText - Any legal SQL statement

executeQuery

public any executeQuery(any sqlQueryText)
Alias for exec_query.

Parameters:
any sqlQueryText - Any legal SQL statement

find_all

public any find_all([any orderBy=""], [any filter])
Finds all records of the model's type

Parameters:
[any orderBy=""]
[any filter]

find_by_id

public any find_by_id(any id)
Finds a record of this type given its ID.

Parameters:
any id - The ID of the record you want to find.

findAll

public any findAll([any orderBy=""])
Alias for find_all

Parameters:
[any orderBy=""]

findByID

public any findByID(any id)
Alias for find_by_id

Parameters:
any id - The ID of the record you want to find.

get_columns_properties

public any get_columns_properties([string whichColumn=""])
Alias for getColumnsProperties().

Parameters:
[string whichColumn=""]

get_human_name

public string get_human_name(string columnName)
Parameters:
string columnName

get_table_name

public any get_table_name()
Alias for getTableName().


getColumnsProperties

public any getColumnsProperties([string whichColumn=""])
Returns a query containing the model's columns properties: name, type, is_nullable, max_length, default_value, and priority. The records returned are sorted in order of priority, ascending.

Parameters:
[string whichColumn=""] - Optional argument is used to specify only one column to get this information for.

getPrimaryKey

public any getPrimaryKey()

getTableName

public any getTableName()

init

public any init([struct params="#structNew()#"])
returns the properly instantiated derivative of Model

Parameters:
[struct params="#structNew()#"] - A structure containing the values for the model's columns. It can contain more or less fields than the actual model - only those that match will be set.

save

public any save()
If the id is set, updates the table with the values in the fields. Otherwise, it inserts them.


set_human_name

public any set_human_name(string columnName, string humanName)
Sets the human name of a column.

Parameters:
string columnName - The name of the column whose priority you want to set.
string humanName - The new human name the column should have.

set_priority

public any set_priority(string columnName, numeric priority)
Sets the priority of a column. Also increases each priority coming 'after' the value passed by one, to break any ties. In effect, this method 'inserts' the column into row specified.

Parameters:
string columnName - The name of the column whose priority you want to set.
numeric priority - The new priority number the column should have.

setPrimaryKey

public any setPrimaryKey([any pkname])
Parameters:
[any pkname]