Smutty_Object
|
+--Smutty_Model
public class Smutty_Model
extends Smutty_Object
| Field Summary | |
|---|---|
| mixed | allows specifying dependent models by their name. |
| mixed | |
| mixed | |
| mixed | enable rss output for this model */ |
| mixed | the name of this models table, defaults to false so it will be |
| mixed | this property should be used to specify how data is to |
| Constructor Summary | |
|---|---|
constructor |
|
| Method Summary | |
|---|---|
| boolean | delete() deletes the current model from the database |
| static nothing | deleteWhere(String class, array params) this method allows deleting of multiple records |
| boolean | exists(String id) determines if a record with the specified id currently exists in this models table |
| static array | fetchAll(String class, String order, array params, mixed whereSql, array joins, String limit) returns all the records for this model |
| nothing | fill() this method tries to automatically fill a model with data that has been passed to the application. |
| static Smutty_Model | find(String class, String id, String field) this function allows searching for a record by it's unique id. |
| array | returns an array containing any errors that were encountered the last time the model was validated. |
| static array | getFields(String class) returns an array of this models fields and their types |
| private static void | getJoinSql(String fromAlias, String joins) returns the sql to do a join to the dot seperated list of models specified. |
| static int | getTotal(String class) returns the total number of records for the model |
| boolean | isValid() this function checks if the models data is currently in a valid state to be saved. |
| boolean | save() this function saves a models data, it returns a boolean indicating if the save went ahead ok or not. |
public mixed $hasMany = ''
allows specifying dependent models by their name. the related
public mixed $hasOne = ''
public mixed $hasRelation = ''
public mixed $rss = ''
enable rss output for this model */
public mixed $tableName = false
the name of this models table, defaults to false so it will be
public mixed $validate = array()
this property should be used to specify how data is to
public Smutty_Model()
constructor
public boolean delete()
deletes the current model from the database
public static nothing deleteWhere(String class, array params)
this method allows deleting of multiple records
public boolean exists(String id)
determines if a record with the specified id currently exists in this models table
public static array fetchAll(String class, String order, array params, mixed whereSql, array joins, String limit)
returns all the records for this model
public nothing fill()
this method tries to automatically fill a model with data that has been passed to the application.
public static Smutty_Model find(String class, String id, String field)
this function allows searching for a record by it's unique id. if it is found then an instance of it's model object will be returned, otherwise you'll get false.
public array getErrors()
returns an array containing any errors that were encountered the last time the model was validated.
public static array getFields(String class)
returns an array of this models fields and their types
private static void getJoinSql(String fromAlias, String joins)
returns the sql to do a join to the dot seperated list of models specified. an inner join is used.
eg. getJoinSql( 'Post', 'User.UserType' );
public static int getTotal(String class)
returns the total number of records for the model
public boolean isValid()
this function checks if the models data is currently in a valid state to be saved. this means that all validation criteria that have been specified need to be met.
errors are stored in $this->errors and can be accessed by using the $this->getErrors() function.
public boolean save()
this function saves a models data, it returns a boolean indicating if the save went ahead ok or not.
this is the base class for all Smutty models. it provides many methods and utilities which (hopefully) make using models the joy it should be.
/