Build Model Properties, Relations and Methods on a given database table
If you designed a child class, extending model, to describe a specific class, ou may use Build() function to mount it automatically
USAGE
$Class = new \xuserver\v5\model() ; $Class->build("customer") ;
@parammixed$values
- Retrieve modelproperty values in a stdClass object
- null : set properties to null (reset object)
- Array : set modelproperty values using array key and values (typically $_POST)
- Object : set modelproperty values using object property values (can be a stdClass or a model object)
// change values on customer and create new one $NewCustomer = $customer->create($_POST) ; // copy customer $NewCustomer = $customer->create() ;
@returnmodel
if Database insert is ok, The new Model Instance is retured, otherwise the calling instance itself @parammixed$values Array | model
if given set val($values) is fired on current Model Instance @todo dont change values on current instance
This Event is fired when model is turned into formular
This event is overridden in descendant class files
It is used to manage formular field presentation and design
The modelStructure class is an iteratorItem child that olds Methods :
- to launch PHP overloading Functions over a model(set, get, call, invoke)
- to access and traverse Model structure (properties, methods, relations, iterator (to be renamed))
- to access database and sql classes
- to describe the Model : __module()
@paramdatabase$db
if no db given, the system will use the database defined in config.php file
public__set()
modelStructure::__set()
OVERLOADING
Set instance property values using overloading
This reduces the code to use to manipulate model "meta Properties"
USAGE
// change customer name on customer model // full syntax is $customer->properties()->find("customerName")->val("change the name") ;
// short syntax is $customer->customerName = "change the name"; // meta tag syntax also working to set value $customer->§customerName = "also change the name";
@paramstring$name
The $name of the designated overloaded meta property
note : you can also name properties using "§" meta tag @parammixed$value
Value given to the overloaded meta property @seeproperty @seeproperties
public__get()
modelStructure::__get()
OVERLOADING
Return a the value of a "meta Property".
USAGE
// using "§" meta tag , the meta property itself is returned $prop = $customer->§customerName; $prop->val("change the value") ; // without "§" meta tag , property::val() is returned
@paramstring$name
The name of the designated overloaded meta property
note : When you use "§" meta tag , the property is returned
note : When you do not use "§" meta tag , the property value is returned @return \xuserver\v5\property |string
Return the name of the database table that stores the model @returnstring
publicdb_index()
modelStructure::db_index()
Return the name of the database field that stores the model primary key @returnstring
publicdb_id()
modelStructure::db_id()
Set or Retrieve the value model primary key in database @paramstring$set
value can be either an integer or an array of integers
if null or 0 given, the model will act like a selection @return \xuserver\v5\modelStructure|string
publichref()
modelStructure::href()
Return model a string that references the model instance