You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?phpclass FooEntityFactory extends AbstractFactory
{
// ...// override this methodprotectedfunctionpersistEntity($entity): void
{
/** @var FooEntity $entity */$pdo = new \PDO('mysql:host=localhost;dbname=foo_db', 'user', 'password');
$stmt = $pdo->prepare('INSERT INTO foo (name) VALUES (:name)');
$stmt->bindValue(':name', $entity->getName());
$stmt->execute();
}
}
// call store method when you want to store an entity in database$foo = FooEntityFactory::start()->store();