protected function setUp() { $this->court = new Court(true); $this->entityManager = GetEntityManager(); $this->courtRepository = $this->entityManager->getRepository('AppBundle\\Entity\\Court'); $this->total = count($this->courtRepository->findAll()); }
public static function setUpBeforeClass() { self::$entityManager = GetEntityManager(); // Build the schema for sqlite self::generateSchema(); $newCustomer = new Customer(); $newCustomer->setActive(true); $newCustomer->setName('Name 1'); self::$entityManager->persist($newCustomer); $newPost = new Post(); $newPost->setCustomer($newCustomer); $newPost->setDate(new \DateTime('2016-07-12 16:30:12.000000')); $newPost->setDescription('Description test'); self::$entityManager->persist($newPost); $newComment = new Comment(); $newComment->setPost($newPost); $newComment->setComment('Comment 1'); self::$entityManager->persist($newComment); $newComment2 = new Comment(); $newComment2->setPost($newPost); $newComment2->setComment('Comment 2'); $newComment2->setParentComment($newComment); self::$entityManager->persist($newComment2); self::$entityManager->flush(); self::$classConfig = [CustomerMapping::class, PostMapping::class, CommentMapping::class]; parent::setUpBeforeClass(); }
<?php require_once __DIR__ . '/../../config/bootstrap.php'; //Get all courts $entityManager = GetEntityManager(); $courtRepository = $entityManager->getRepository('AppBundle\\Entity\\Court'); $courts = $courtRepository->findAll(); //Print all courts echo sprintf(" %2s: %10s\n", 'Id', 'Active:'); foreach ($courts as $court) { echo sprintf("- %2d: %10s\n", $court->getId(), $court->getActive() ? 'true' : 'false'); } echo "\nTotal: " . count($courts) . " courts.\n\n";
<?php require_once __DIR__ . '/../../../config/bootstrap.php'; if ($argc < 2) { echo "Usage: " . basename(__FILE__) . " ids=id_1,id_2,...,id_n" . PHP_EOL; exit; } $cmd_data = []; parse_str(implode('&', array_slice($argv, 1)), $cmd_data); $groups_ids = explode(',', $cmd_data['ids']); $em = GetEntityManager(); $groupRepository = $em->getRepository('AppBundle\\Entity\\Group'); foreach ($groups_ids as $group_id) { $group = $groupRepository->find($group_id); if ($group) { $em->remove($group); echo "Removed group: {$group_id}" . PHP_EOL; } else { echo "Group with id {$group_id} was not found" . PHP_EOL; } } $em->flush();
function eventadd() { $em = GetEntityManager(); $titre = $_POST['titre']; $description = $_POST['description']; $id_sport = $_POST['sport']; $sport = $em->find('Sport', $id_sport); $lieu = $_POST['lieu']; $date = $_POST['date']; $events = $em->getRepository('Evenement')->findAll(); if ($titre == "" || $lieu == "" || $date == "") { operation_error("Le nom est vide"); } else { $event = new Evenement($sport, $date, $lieu, $titre, $description); $em->persist($event); $em->flush(); operation_success(); } header('Location: ?/admin'); }
<?php /** * based on cli-config.php from * http://doctrine-orm.readthedocs.io/projects/doctrine-orm/en/latest/reference/configuration.html */ use Doctrine\ORM\Tools\Console\ConsoleRunner; require_once __DIR__ . '/../tests/Integrations/Doctrine/bootstrap.php'; //global $entityManager from boostrap.php return ConsoleRunner::createHelperSet(GetEntityManager());