SQL TABLE
Client Table
+--+----+
|id|name|
+--+----+
|1 |Jhon|
+--+----+
Sensor System Table
+--+----+---------+
|id|name|client_id|
+--+----+---------+
|1 |sys1|1 |
+--+----+---------+
client_id -> foreign key client(id)
ENTITY PHP
class Client
{
private $id;
private $name;
private $sensorSystem;
}
class SensorSystem
{
private $id;
private $name;
}
Well, when I need to add a new sensor system to the database, the Service must pass both entities (Client, SensorSystem) to the DAO and then the DAO will evade the responsibility of converting the entity data into the table fields; or is the Service having the responsibility to divide the entity data into an array (['idSensor' => '1', 'nameSensore' => 'name', 'idClient' => '1']
) and then pass the array to the DAO ??
I know that Serivice is handling the entity data and DAO to manipulate data in the database, but given the different data structures, who has the responsibility to convert table data into entity attributes and vice versa?
Aucun commentaire:
Enregistrer un commentaire