Skip to content

Working with objects

ccapndave edited this page Feb 26, 2011 · 14 revisions

This section of the documentation will explain how to work with entities (objects) in Flextrine. Specifically we will talk about how to load, save, update and delete objects with Flextrine.

Where's my CRUD?

Many client/server systems for reading and writing follow the CRUD paradigm (Create, Read, Update, Delete) as it maps neatly to SQL and generally allows for clean row based operations on the database. Unfortunately the simple CRUD approach starts to become more complex if you want to represent a row with an Object, and can end up very complicated indeed once you have relationships between those objects.

An ORM system like Flextrine is built from the ground up to work with objects instead of rows. In fact, the general idea is that from the perspective of your application there are no tables, rows or columns, only stores of objects. The ORM system takes care of translating operations on your objects into SQL calls, and results from SQL calls back into objects.

Transactional write-behind

Flextrine and Doctrine employ a pattern called 'Transactional write-behind'. This means that any write operations (i.e. operations that will cause a change in the database) are queued up until the command is given to actually apply them. This is especially valuable for an asynchronous client/server system like Flextrine as server calls are relatively expensive. The queue is executed using the em.flush() method, or the queue can be abandoned and entities returned to their original state using em.rollback(). See the Flush-and-rollback chapter for more details.

Persisting entities (Create)

Clone this wiki locally