Bienvenue

Nov/2020

xuServer est un Framework ORM français, écrit en PHP pour des bases de données MySQL.

Objectifs & Caractéristiques :

  • Encapsulation des concepts de Programmation Orientée Objet
  • Syntaxe POO chainable
  • Facilitation du développement de fontionnalités métier par les utilisateurs finaux
  • Namespacing et Modularité (gestion de droits, fonctionnalités métier ...)
  • Génération automatique des interfaces utilisateurs
  • Cet environnement de développement léger se fonde sur l'emploi de :

  • PHP 7.x
  • MySQL 5.x
  • jQuery 3.4
  • Bootstrap 4
  • Page de Démonstration

    L'accès au service dépend de vos droits d'utilisateur.

    Merci de bien vouloir créer un compte et vous y connecter

    Documentation

    La documentation de l'API est disponible ici (version béta)

    Open Source GPAO

    Contact

    A propos du webmaster




    model


    ORM Model class

    Common public methods of model object

    @author gael jaunin

    INHERITANCE

    public build()

    model::build()

    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") ;

    EXAMPLES



    @param string $db_tablename
    The name of the table to Modelize

    @return \xuserver\v5\model

    @see properties, methods, relations



    public title()

    model::title()

    Get or Set the Model instance "title"

    EXAMPLES



    @param string $set
    @return \xuserver\v5\model | string | boolean | string

    @todo rename $titleProp
    @todo bring together title() , $_title and $_titleArray



    public val()

    model::val()

    Get or Set tme Model property values

    USAGE

    // form submit
    $customer->val($_POST) ;
    EXAMPLE



    @param mixed $values
    - Retrieve model property values in a stdClass object
    - null : set properties to null (reset object)
    - Array : set model property values using array key and values (typically $_POST)
    - Object : set model property values using object property values (can be a stdClass or a model object)

    @see \xuserver\v5\iteratorItem::val()



    public create()

    model::create()

    Create model instance or selection in Database

    USAGE

    // change values on customer and create new one
    $NewCustomer = $customer->create($_POST) ;
    // copy customer
    $NewCustomer = $customer->create() ;

    @return model
    if Database insert is ok, The new Model Instance is retured, otherwise the calling instance itself
    @param mixed $values Array | model
    if given set val($values) is fired on current Model Instance
    @todo dont change values on current instance



    public read()

    model::read()

    read model instance from database
    @param number $id
    @return \xuserver\v5\model



    public update()

    model::update()

    update model instance or selection
    @param mixed $values



    public delete()

    model::delete()

    delete model instance or selection
    @param mixed $values



    public append()

    model::append()

    Append an item in a relation
    @param string $relationName
    @return string



    public formular()

    model::formular()

    Return a user designed formular type, using model->ui->form() method
    This method is very usefull in herited module developpement

    @param string $type (typically "create, "search", "register")
    @return string (html form)



    public disk()

    model::disk()

    Retrieve stdClass representing the "physical directory"
    where the model will store the uploaded files (sent by form)

    @see model::OnUpload()
    @param boolean $create
    @return \stdClass



    public auth()

    model::auth()

    applies the auth module on the model, its relations and foreign keys
    @param \session $session
    @return \xuserver\v5\model





    modelEvents


    ORM Model Event class

    Events are fired on model public method execution :
    - create()
    - read()
    - update()
    - delete()

    They can be overwritten in descendant class files.


    INHERITANCE

    protected OnBuild()

    modelEvents::OnBuild()

    This Event is fired when model is Built
    Use it to assign properties types, requided, comments and so on

    @see model::build()



    protected OnFormular()

    modelEvents::OnFormular()

    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

    @see model::formular($type)
    @param string $type




    protected OnSelection()

    modelEvents::OnSelection()

    This Event is fired when model state becomes a "selection"
    Use it to assign properties types, requided, comments ...

    @see model::read()



    protected OnInstance()

    modelEvents::OnInstance()

    This Event is fired when model state becomes an "instance"
    Use it to assign properties types, requided, comments ...

    @see model::read()



    protected OnUpdate()

    modelEvents::OnUpdate()

    This Event is fired when model is updated
    Use it to realize special treatments after object update

    @see model::update($id)



    protected OnCreate()

    modelEvents::OnCreate()

    This Event is fired when model is created
    Use it to realize special treatments once new instance is created

    @see model::create()



    protected OnDelete()

    modelEvents::OnDelete()

    This Event is fired when model is deleted
    Use it to realize special treatments

    @see model::delete()



    protected OnUpload()

    modelEvents::OnUpload()

    This Event is fired when model is updated

    @see model::update()
    @return \xuserver\v5\model





    modelStructure


    ORM MODEL STRUCTURE CLASS

    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()

    INHERITANCE

    public __construct()

    modelStructure::__construct()

    Constructor for model structure and children

    @param database $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";

    @param string $name
    The $name of the designated overloaded meta property
    note : you can also name properties using "§" meta tag
    @param mixed $value
    Value given to the overloaded meta property
    @see property
    @see properties




    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


    @param string $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



    public __call()

    modelStructure::__call()

    OVERLOADING


    otherwise ;
    @param string $name
    @return \xuserver\v5\property|string



    public __invoke()

    modelStructure::__invoke()

    OVERLOADING


    @todo reflechir a son emploi
    @return \xuserver\v5\iterator



    public __module()

    modelStructure::__module()

    Return the name of the module the model (or its descendant) belongs to
    Module name is defined parsing namespaces of descendant class
    @return string



    public __reset()

    modelStructure::__reset()

    Init model interface, reseting its modelStructure properties



    public iterator()

    modelStructure::iterator()

    Traversing modelStructure
    Return the iterator object that stores the list of instances

    @see \xuserver\v5\model
    @return \xuserver\v5\iterator



    public properties()

    modelStructure::properties()

    Traversing modelStructure
    Return the iterator object that stores the list of property

    @see \xuserver\v5\property
    @return \xuserver\v5\properties



    public relations()

    modelStructure::relations()

    Traversing modelStructure
    Return the iterator object that stores the list of relation

    @see \xuserver\v5\relation
    @return \xuserver\v5\relations



    public methods()

    modelStructure::methods()

    Traversing modelStructure
    Return the iterator object that stores the list of method

    @see \xuserver\v5\method
    @return \xuserver\v5\methods



    public sql()

    modelStructure::sql()

    Traversing modelStructure

    Return the sql ORM driver
    @return \xuserver\v5\sql



    public db()

    modelStructure::db()

    Traversing model structure
    Return the database object on which PDO queries are executed

    @return \xuserver\v5\database



    public db_tablename()

    modelStructure::db_tablename()


    Return the name of the database table that stores the model
    @return string



    public db_index()

    modelStructure::db_index()

    Return the name of the database field that stores the model primary key
    @return string



    public db_id()

    modelStructure::db_id()

    Set or Retrieve the value model primary key in database
    @param string $set
    value can be either an integer or an array of integers
    @return \xuserver\v5\modelStructure|string



    public href()

    modelStructure::href()

    Return model a string that references the model instance

    USAGE

    $customer->href() ;
    // return "customer-1"

    EXAMPLES



    @see router.php
    @see \xs_encrypt()
    @see \xs_link()
    @return string



    public state()

    modelStructure::state()

    set model current _state
    model state can be virgin, instance, selection

    @param string $set
    @return \xuserver\v5\model|string





    iteratorItem


    standard item in iterator


    INHERITANCE

    public type()

    iteratorItem::type()

    Set or Retrieve the item type

    @param string $set
    @return \xuserver\v5\iteratorItem|string