Vanilla 2  2.0.18.8
 All Data Structures Namespaces Files Functions Variables Pages
Gdn_Model Class Reference
Inheritance diagram for Gdn_Model:
Collaboration diagram for Gdn_Model:

Public Member Functions

 __construct ($Name= '')
 
 DefineSchema ()
 
 Save ($FormPostValues, $Settings=FALSE)
 
 Insert ($Fields)
 
 Update ($Fields, $Where=FALSE, $Limit=FALSE)
 
 Delete ($Where= '', $Limit=FALSE, $ResetData=FALSE)
 
 FilterForm ($Data)
 
 FilterSchema ($Data)
 
 Get ($OrderFields= '', $OrderDirection= 'asc', $Limit=FALSE, $Offset=FALSE)
 
 GetCount ($Wheres= '')
 
 GetID ($ID, $DatasetType=FALSE)
 
 GetWhere ($Where=FALSE, $OrderFields= '', $OrderDirection= 'asc', $Limit=FALSE, $Offset=FALSE)
 
 ValidationResults ()
 
 Validate ($FormPostValues, $Insert=FALSE)
 
 SaveToSerializedColumn ($Column, $RowID, $Name, $Value= '')
 
 SetProperty ($RowID, $Property, $ForceValue=FALSE)
 
- Public Member Functions inherited from Gdn_Pluggable
 __construct ()
 
 GetReturn ($PluginName, $HandlerName)
 
 FireEvent ($EventName)
 
 __call ($MethodName, $Arguments)
 
- Public Member Functions inherited from Gdn_SliceProvider
 EnableSlicing (&$Sender)
 
 Slice ($SliceName, $Arguments=array())
 
 AddSliceAsset ($Asset)
 
 RenderSliceConfig ()
 

Data Fields

 $Data
 
 $Database
 
 $DateInserted = 'DateInserted'
 
 $DateUpdated = 'DateUpdated'
 
 $InsertUserID = 'InsertUserID'
 
 $Name
 
 $PrimaryKey = 'id'
 
 $Schema
 
 $SQL
 
 $UpdateUserID = 'UpdateUserID'
 
 $Validation
 
- Data Fields inherited from Gdn_Pluggable
 $EventArguments
 
 $Returns = array()
 
 $HandlerType
 

Protected Member Functions

 _BeforeGet ()
 
 AddInsertFields (&$Fields)
 
 AddUpdateFields (&$Fields)
 

Additional Inherited Members

- Protected Attributes inherited from Gdn_Pluggable
 $ClassName
 
- Protected Attributes inherited from Gdn_SliceProvider
 $SliceHandler
 
 $SliceConfig
 

Constructor & Destructor Documentation

__construct (   $Name = '')

Class constructor. Defines the related database table name.

Parameters
string$NameAn optional parameter that allows you to explicitly define the name of the table that this model represents. You can also explicitly set this value with $this->Name.

Here is the call graph for this function:

Member Function Documentation

_BeforeGet ( )
protected

A overridable function called before the various get queries.

Here is the caller graph for this function:

AddInsertFields ( $Fields)
protected

Adds $this->InsertUserID and $this->DateInserted fields to an associative array of fieldname/values if those fields exist on the table being inserted.

Parameters
array$FieldsThe array of fields to add the values to.

Here is the call graph for this function:

Here is the caller graph for this function:

AddUpdateFields ( $Fields)
protected

Adds $this->UpdateUserID and $this->DateUpdated fields to an associative array of fieldname/values if those fields exist on the table being updated.

Parameters
array$FieldsThe array of fields to add the values to.

Here is the call graph for this function:

Here is the caller graph for this function:

DefineSchema ( )

Connects to the database and defines the schema associated with $this->Name. Also instantiates and automatically defines $this->Validation.

Here is the caller graph for this function:

Delete (   $Where = '',
  $Limit = FALSE,
  $ResetData = FALSE 
)
Parameters
unknown_type$Where
unknown_type$Limit
unknown_type$ResetData
Todo:
add doc

Here is the call graph for this function:

Here is the caller graph for this function:

FilterForm (   $Data)

Filter out any potentially insecure fields before they go to the database.

Parameters
array$Data

Here is the caller graph for this function:

FilterSchema (   $Data)

Returns an array with only those keys that are actually in the schema.

Parameters
array$DataAn array of key/value pairs.
Returns
array The filtered array.
Get (   $OrderFields = '',
  $OrderDirection = 'asc',
  $Limit = FALSE,
  $Offset = FALSE 
)
Parameters
unknown_type$OrderFields
unknown_type$OrderDirection
unknown_type$Limit
unknown_type$Offset
Returns
unknown
Todo:
add doc

Here is the call graph for this function:

GetCount (   $Wheres = '')

Returns a count of the # of records in the table

Parameters
array$Wheres

Here is the call graph for this function:

Here is the caller graph for this function:

GetID (   $ID,
  $DatasetType = FALSE 
)

Get the data from the model based on its primary key.

Parameters
mixed$IDThe value of the primary key in the database.
string$DatasetTypeThe format of the result dataset.
Returns
Gdn_DataSet

Here is the call graph for this function:

Here is the caller graph for this function:

GetWhere (   $Where = FALSE,
  $OrderFields = '',
  $OrderDirection = 'asc',
  $Limit = FALSE,
  $Offset = FALSE 
)

Get a dataset for the model with a where filter.

Parameters
array$WhereA filter suitable for passing to Gdn_SQLDriver::Where().
string$OrderFieldsA comma delimited string to order the data.
string$OrderDirectionOne of asc or desc
int$Limit
int$Offset
Returns
Gdn_DataSet

Here is the call graph for this function:

Here is the caller graph for this function:

Insert (   $Fields)
Parameters
unknown_type$Fields
Returns
unknown
Todo:
add doc

Here is the call graph for this function:

Here is the caller graph for this function:

Save (   $FormPostValues,
  $Settings = FALSE 
)

Takes a set of form data ($Form->_PostValues), validates them, and inserts or updates them to the datatabase.

Parameters
array$FormPostValuesAn associative array of $Field => $Value pairs that represent data posted from the form in the $_POST or $_GET collection.
array$SettingsIf a custom model needs special settings in order to perform a save, they would be passed in using this variable as an associative array.
Returns
unknown

Here is the call graph for this function:

SaveToSerializedColumn (   $Column,
  $RowID,
  $Name,
  $Value = '' 
)

Here is the call graph for this function:

SetProperty (   $RowID,
  $Property,
  $ForceValue = FALSE 
)

Here is the call graph for this function:

Update (   $Fields,
  $Where = FALSE,
  $Limit = FALSE 
)
Parameters
unknown_type$Fields
unknown_type$Where
unknown_type$Limit
Todo:
add doc

Here is the call graph for this function:

Here is the caller graph for this function:

Validate (   $FormPostValues,
  $Insert = FALSE 
)
Parameters
unknown_type$FormPostValues
unknown_type$Insert
Returns
unknown
Todo:
add doc

Here is the call graph for this function:

Here is the caller graph for this function:

ValidationResults ( )

Returns the $this->Validation->ValidationResults() array.

Returns
unknown
Todo:
add return type

Here is the caller graph for this function:

Field Documentation

$Data
$DateInserted = 'DateInserted'
$DateUpdated = 'DateUpdated'
$InsertUserID = 'InsertUserID'
$Name
$PrimaryKey = 'id'
$Schema
$SQL
$UpdateUserID = 'UpdateUserID'
$Validation

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