本文整理汇总了PHP中GetEntityManager函数的典型用法代码示例。如果您正苦于以下问题:PHP GetEntityManager函数的具体用法?PHP GetEntityManager怎么用?PHP GetEntityManager使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetEntityManager函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
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());
}
示例2: setUpBeforeClass
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();
}
示例3: GetEntityManager
<?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";
示例4: basename
<?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();
示例5: eventadd
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');
}
示例6:
<?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());