TO DO

dscore

dscore_model

Implement all of your models as classes that extend the dscore_model class.

You must include your own constructor that defines a field map of model properties to database fields.

Sample minimal class:

class dscore_model_sample extends dscore_model { function __construct(dscore $core, int $id = null) { $fieldMap = [ 'id' => 'id', 'name' => 'name' ]; parent::__construct($core, $fieldMap, 'sample', $id); } }

Defining the Model's Field Map

The field map tells the model class what properties your model has and how they work. You define this field map as an array where the keys are the model's property names and the values are the settings for that property.

The simplest method is to map a model property name, specified as the array key, to the database table's field name, as the array value. For example: 'userName' => 'user_name' This would map the model's userName property to the user_name field in the database table.

For anything more complex the array value must be an array that has various options you can specify. The possibilities are:

fieldThe database table's field name. This is required.

modifyOptional. Set to FALSE to make the property read-only. Defaults to TRUE allowing changes to the property.

saveOptional. Only useful if 'modify' is set to FALSE. If 'modify' is FALSE and 'save' is TRUE this property will be saved to the database on updates. This allows you to have other logic that update's a read-only property and still save the property to the database.

virtualOptional. If set to TRUE the property does not map to a database table field. Instead you have to implement custom setter and getter functions for the property.

writeOptional. Only useful if 'virtual' is set to TRUE. Define the name of your setter callback function in your model class.

dscore_request

Accessible from the $core->request property.

client_ipv4The client's IPv4 address.

methodThe request method such as 'GET' or 'POST'.