Models
Database models are responsible for creating and map the data for specific table
Models are automatically detected and as time there is a new table created, it also creates or inject the model for that specific table.
Example:
For example, we have 3 tables
Table
Fields
Model
news
id, name, status
News
news_details
id, news_id, content
NewsDetails
news_attachments
id, news_details_id, url
NewsAttachments
The model part is already introduced here: insert
Usage:
$news = new News();
$news->name = 'My News';
$news->status = 'ACTIVE';
$db->news->insert($news);
$news = $db->news->findOne(1);
$news->name = 'My News';
$news->status = 'ACTIVE';
$db->news->save($news);
Last updated