1
I would like a tip on 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();
}
}
I managed to solve the situation without using Doctrine I thank you for the answer and the solution.
– Ilines