User Tools

Site Tools


database

Database management

Transactions

Sugoi leverage the benefits of MySQL's InnoDB engine : Every page call is wrapped in a transaction.

This ensures there won't be unconsistent datas in the database if an exception occurs. ( the framework will rollback if an exception is thrown )

This means you must lock an object to be able to modify it :

//ask to lock the object when we get it ( 'true' param )
var user = db.User.manager.get(1,true);
user.name = "Bob";
user.update();

Or lock the object later, only when we need it :

user.lock();
user.name = "Bob";
user.update();

dbadmin

The DbAdmin library could be described as a simple database management interface for record-macros.

Its editing features are quite simple but its main strength is that it will migrate the database schema, in sync with the models you defined in your code.

Try to go to http://localhost/db in the sugoi-demo project to see it in action (you'll need to be logged as admin).

If there is a difference between the models and the database schema, a “synchronize” button will appear and will update the schema accordingly.