Introducing The ORM Component
The Object Relational Mapping Component is a great and elegant tool for retrieving and manipulating database tables data with just a couple of lines of code. The class can be used with the PtcEvent component to add event listeners to queries. This class can also be used to call methods from the PtcQueryBuilder component directly. Retrieved rows can be converted to arrays or json arrays. The PtcMapper can also use shortcut methods to retrieve / update single column values.
Main Features:
- Simple syntax to manipulate and insert rows
- Uses shortcuts to retrieve / update single column value
- Can be used with PtcEvent component to add event listeners to queries
- Uses the PtcQueryBuilder class to handle all queries
- Retrieved records can be easily converted to json arrays
- Can use any connection configured with the PtcDb class
Getting Started
To start using the Object Relational Mapping component, alll we need to do is include the file PtcMapper.php and create an extended class:
- // the database table name will be the class name
-
class MY_Table extends PtcMapper{}
Now that we have extended the component, we can start inserting and updating records for the table:- // getting record by id
For a complete list of options and examples read the full user guide.
**If you like this class, help the project to grow by rating or writing a review at one of the following sites: