I would like a hint of how to loop to insert an object into the mysql / postgres database ...
Example
class User {
// PRIMARY KEY
public $id;
public $login;
// PRIMARY FOIREIGN KEY
public $people;
__construct() {
$this->id = -1;
$this->login = "";
$this->people = new People();
}
}
class People {
// PRIMARY KEY
public $id;
public $name;
__construct() {
$this->id = -1;
$this->name = "";
}
}
class Controller {
$em = EntityManager();
$em->beginTrasaction();
$user = new User();
$user->setLogin('admin');
$bool = $em->persist($user);
if($bool) {
$em->commit();
} else {
$em->rollBack();
}
}