Answer the question
In order to leave comments, you need to log in
How to design a model class to work with a relational table?
Good afternoon!
Class example:
class FirstModel {
/** @var int */
private $id;
/** @var string */
private $name;
/** @var string */
private $created;
/** @var string */
private $modified;
/** @var Type */
private $type;
/** @var Settings */
private $settings;
/** @var Settings */
private $order_settings;
/** @var Currency */
private $currency;
}
`model_table` (
`id` int(10) unsigned NOT NULL DEFAULT '0',
`type_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`currency_id` smallint(5) unsigned NOT NULL,
`name` varchar(100) NOT NULL DEFAULT '',
`settings` text NOT NULL,
`order_fields` text NOT NULL,
`modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
)
Answer the question
In order to leave comments, you need to log in
Bicycles are bad. I advise you to look at the implementation of the Data Mapper and Active Record patterns.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question