Skip to content

Latest commit

 

History

History
178 lines (119 loc) · 4.59 KB

db-html.rst

File metadata and controls

178 lines (119 loc) · 4.59 KB

Note

In this part, your project is already created. If you do not have a mysql database on hand, you can download this one: messagerie.sql </model/messagerie.sql>

Configuration

Check the database configuration with webtools at http://127.0.0.1:8090/Admin/:

Go to models part:

image

Note

The configuration file is located in app/config/config.php

Change the configuration of the database to use the messagerie database:

  • Click on the Edit config file button
  • Select the database part

image

  • Enter messagerie in the dbName field
  • Click on Test button to check the connection
  • Validate with the Save configuration button

image

Generation

To generate all models, click on (Re-)create all models button.

image

Generate the models cache by clicking on Re-init all models cache button:

image

That's all! The models are generated and operational. You can now see datas.

Note

It is possible to generate models automatically when creating a project with the -m option for models and -b to specify the database:

Ubiquity new quick-start -a  -m -b=messagerie 

Navigation between data

You can now see the data and move between related objects:

image

You can also perform basic operations on objects:

  • Create
  • Read (navigate and see)
  • Update
  • Delete
  • Search

Checking

Class diagram

Still in the models part, click on the models generation step:

image

Then click on Classes diagram button:

image

You can see the class diagram, using the yUML API

image

Models meta-datas

To see the metadatas of a created model:

Select a model, and activate the Structure tab:

image

You can also view the partial class diagram:

image

Models validation

The third tab gives information about object validation:

image

Note

The validation rules were generated automatically with the classes. They are defined through @validator annotations on each member of a class and are stored in cache.

The Validate instances button is used to check the validity of the instances:

image

Note

It is normal that by default all instances in the database do not check all validation rules.

Generated classes

Generated classes are located in app/models folder, if the configuration of mvcNS.models has not been changed.

Note

If you want to know more about:

  • object/relational mapping rules, see the ORM part</model/models>
  • data querying and persistence, see DAO part</model/dao>

The Settings class:

namespace models;
class Settings{
    /**
     * @id
     * @column("name"=>"id","nullable"=>false,"dbType"=>"int(11)")
     * @validator("id","constraints"=>array("autoinc"=>true))
    **/
    private $id;

    /**
     * @column("name"=>"name","nullable"=>true,"dbType"=>"varchar(45)")
     * @validator("length","constraints"=>array("max"=>45))
    **/
    private $name;

    /**
     * @oneToMany("mappedBy"=>"settings","className"=>"models\\Organizationsettings")
    **/
    private $organizationsettingss;
}

Important

Any modification on the classes (code or annotations) requires the reset of the cache to be taken into account.

Ubiquity init-cache -t=models