-
getDi() : void
-
getDb() : void
-
-
-
getPrimary() : void
-
-
-
getFilters() : void
-
-
getFields() : void
-
-
getValidation() : void
-
getRelations() : void
-
-
getMessages() : void
-
-
Model constructor. Fetch Di and set it as a property.
-
getId() : voidGet the id.
-
getIdKey() : stringGet the id key depending on db driver.
-
Get the date time object.
-
Load one result to the current object.
-
Load results to the current object.
-
Allows to query one record that match the specified conditions.
-
Allows to query all records that match the specified conditions.
-
Prepare fields for validation on create/update.
-
Insert a new object to the database.
-
Update an existing object in the database.
-
Inserts or updates a model instance. Returning true on success or false otherwise.
-
Removes a model instance(s). Returning true on success or false otherwise.
-
Get the record if exist.
-
loaded() : boolCheck whether model is loaded.
-
getError() : voidGet the last Db error.
-
Setup a relation reverse 1-1 between two models.
-
Setup a 1-1 relation between two models
-
Setup a relation 1-n between two models.
-
Get related models.
-
Get rules for validation.
-
Set rules for validation.
-
__serialize() : arraySerialize the model's data.
-
Unserialize and set the data.
-
Magic call to get related models.
-
zephir_init_properties_Ice_Mvc_Model() : void
-
public function getDi()
-
public function getDb()
-
public function setFrom(variable $from)
-
public function setPrimary(variable $primary)
-
public function getPrimary()
-
public function setAutoincrement(variable $autoincrement)
-
public function setFilters(variable $filters)
-
public function getFilters()
-
public function setFields(variable $fields)
-
public function getFields()
-
public function setValidation(variable $validation)
-
public function getValidation()
-
public function getRelations()
-
public function setLabels(variable $labels)
-
public function getMessages()
-
public function setMessages(variable $messages)
-
public function __construct(variable $filters, array $data, array $options)
Model constructor. Fetch Di and set it as a property. -
public function getId()
Get the id. -
public function getIdKey()
Get the id key depending on db driver. -
public function getDateTime(variable $key, variable $model)
Get the date time object. -
public function loadOne(variable $filters, array $options)
Load one result to the current object. -
public function load(variable $filters, array $options)
Load results to the current object. -
public static function findOne(variable $filters, array $options)
Allows to query one record that match the specified conditions.//Get the user from users by id 2 $user = Users::findOne(2); echo "The user name is ", $user->username; //Get one active user with age > 18 $user = Users::findOne(array("status" => 1, "age" => array(">" => 18)));
-
public static function find(variable $filters, array $options)
Allows to query all records that match the specified conditions.//Get all active users with age > 18 $user = Users::find(array("status" => 1, "age" => array(">" => 18)));
-
protected function fields(variable $fields, bool $primary)
Prepare fields for validation on create/update. -
public function create(variable $fields, variable $extra)
Insert a new object to the database.//Creating a new user $user = new Users(); $user->lastname = "Kowalski"; $user->status = 1; $user->create();
-
public function update(variable $fields, variable $extra)
Update an existing object in the database.//Updating a user last name $user = Users::findOne(100); $user->lastname = "Nowak"; $user->update();
-
public function save(variable $fields, variable $extra)
Inserts or updates a model instance. Returning true on success or false otherwise.//Creating a new user $user = new Users(); $user->lastname = "Kowalski"; $user->status = 1; $user->save(); //Updating a user last name $user = Users::findOne(100); $user->lastname = "Nowak"; $user->save();
-
public function delete(variable $filters)
Removes a model instance(s). Returning true on success or false otherwise.//Remove current user $user = Users::findOne(100); $user->delete(); //Remove all unactive users $status = (new Users())->delete(["status" => 0]);
-
public function exists(variable $filters)
Get the record if exist. -
public function loaded()
Check whether model is loaded. -
public function getError()
Get the last Db error. -
public function belongsTo(string $field, string $referenceModel, string $referencedField, array $options)
Setup a relation reverse 1-1 between two models.class Posts extends Model { public function initialize() { //Relation with user, be able to get post's author $this->belongsTo('user_id', __NAMESPACE__ . '\Users', 'id', ['alias' => 'User']); } } //Get post's author $post = Posts::findOne(100); echo $post->getUser()->username;
-
public function hasOne(string $field, string $referenceModel, string $referencedField, array $options)
Setup a 1-1 relation between two modelsclass Users extends Model { public function initialize() { $this->hasOne('id', __NAMESPACE__ . '\UsersDescriptions', 'user_id', ['alias' => 'Description']); } }
-
public function hasMany(string $field, string $referenceModel, string $referencedField, array $options)
Setup a relation 1-n between two models.class Users extends Model { public function initialize() { //Relation with posts, be able to get user's posts $this->hasMany('id', __NAMESPACE__ . '\Posts', 'user_id', ['alias' => 'Posts']); } } //Get user's posts $user = Users::findOne(2); foreach ($user->getPosts() as $post) { echo $post->title; }
-
public function getRelated(string $alias, array $filters, array $options)
Get related models. -
public function getRules(variable $fields)
Get rules for validation.// Get rules for one field $this->getRules('password'); // Get rules for multiple fields $this->getRules(['fullName', 'about']); // Get all rules $this->getRules();
-
public function setRules(array $rules, bool $merge)
Set rules for validation. -
public function __serialize()
Serialize the model's data. -
public function __unserialize(array $serialized)
Unserialize and set the data. -
public function __call(string $method, variable $arguments)
Magic call to get related models. -
internal function zephir_init_properties_Ice_Mvc_Model()