Site Administrator
  • Overview
  • Getting Started
    • Installation
    • Configuration
    • Access & Navigation
  • User Guide
    • Dashboard
    • Modules
      • Members
      • Page Editor
      • FAQs
      • News
      • Photo Gallery
      • Forms
      • Catalog
      • Events
      • Staff
    • Settings
  • Developer Guide
    • The Basics
      • Controllers
      • Rendering with Vue JS
      • Responses
      • Routing
      • Views
      • View Models
    • Models & Doctrine ORM
      • Models
      • Entity Manager
      • Repositories
    • Advanced Topics
      • Creating a Module
      • Creating a Theme
      • Events
      • Logging
      • modRequest
      • IOC & Dependency Injection
    • Utilities & Helpers
      • DateTime
      • Doctrine Utils
      • URL
    • Command Line
      • Doctrine CLI
      • Executing Controllers
    • Vue Components
  • Credits
  • Old Guide
    • Site Administrator
      • Site Administrator
Powered by GitBook
On this page
  • Accessing Entity Manager Context
  • Create/Update Entity
  • Remove Entity
  1. Developer Guide
  2. Models & Doctrine ORM

Entity Manager

PreviousModelsNextRepositories

Last updated 7 years ago

Siteadmin uses Doctrine 2 as its internal ORM. All create/update/remove operations are handled through the doctrine entity manager context.

This is just a quick start guide to doctrine's entity manager. Visit the for detailed explanations.

Accessing Entity Manager Context

// Returns doctrine entity manager instance
$entityManager = \sa\application\app::$entityManager

Create/Update Entity

<?php
// Create entity instance
$user = ioc::resolve('User');
​
// Set fields
$user->setFirstName('John')
     ->setLastName('Doe');
​
// Queue changes in entity manager
app::$entityManager->persist($user);
​
// Commit $user object specific changes
app::$entityManager->flush($user);
​
// Commit all persisted changes
app::$entityManager->flush();

Remove Entity

<?php
// $user is an entity which already exists in the entity manager.
app::$entityManager->remove($user);
official documentation