doctrine

Symfony 1.4 with multiple apps and different databases

岁酱吖の 提交于 2019-12-19 10:47:12
问题 I have an important Symfony project, in which I have different apps. I'd like to have different databases, one for each apps. I've find that I can have multiple database connections, but when I create schema, models forms and filters symfony put all these classes into /lib/folder. Is there a way for create models, forms, filters for each application based on his own schema, and put the resulting classes into somthing like /apps/myApp/lib? Thankyou very much... 回答1: You can use the "package"

Is it possible to run the task “symfony doctrine build --all” on only one table?

落花浮王杯 提交于 2019-12-19 10:22:21
问题 If I run the folowing task, it builds everything and wipes out the database: php symfony doctrine build --all I would like this task to run only for the new table that I've put in schema.yml Is it possible ? 回答1: I think you should use migration for that. First, you need to restore the initial state (when schema, model and db are in sync). Remove your changes form schema.yml rebuild your model php symfony doctrine:build --all-classes and import the original database. After that make your

Use Symfony UniqueEntity with Doctrine

我只是一个虾纸丫 提交于 2019-12-19 10:18:26
问题 I am trying to get Symfony's UniqueEntity validator working for my Doctrine entities. The Symfony validator is already hooked up and working, the UniqueEntity from Symfony\Bridge, however, is more challenging, displaying this error: PHP Fatal error: Class 'doctrine.orm.validator.unique' not found in /app/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactory.php on line 46 It appears as if the ValidatorFactory is requesting the UniqueEntity validator from the Symfony

Symfony 4: doctrine in command

痞子三分冷 提交于 2019-12-19 09:06:08
问题 I am using symfony 4 and I want to access a repository for an entity if I am in the Command class. There is not a function getDoctrine or something.. I have created an Entity through the console, so I got an entity and a repository. Does anybody know how I can access the repository? 回答1: The best practice is to delegate this task to a service. See this example: https://symfony.com/doc/current/console.html#getting-services-from-the-service-container However you can also add a constructor to

Using ORM classes directly from the controller in MVC, bad practice?

我只是一个虾纸丫 提交于 2019-12-19 06:14:44
问题 I've recently delved into using an ORM in my CodeIgniter application and one i've gone for is Propel. Now this gives me the power to basically use Propels classes as the 'Model' but is this bad practive? So my controller code would be as follows: <?php class Page extends Controller { function __construct() { parent::__construct(); } function index() { $foo = FooQuery::create()->limit(10)->find(); $data['content'] = array('foo'=>$foo); $this->load->view('home', $foo); } } ?> I want to solve

Generating forms with Symfony 2.8 throws a Twig_Error_Runtime

旧城冷巷雨未停 提交于 2019-12-19 05:04:26
问题 Since the last LTS version of Symfony was released few days ago (30.11.2015) I started playing with it. Unfortunately I can't generate a CRUD with write actions with the same code that works fine in Symfony 2.7.7. First I create a new Symfony project using the bash under Linux Mint 17.2: symfony new tasks lts The new directory tasks gets created with a new Symfony 2.8.0 project inside. After adapting the database credentials in app/config/parameters.yml I create the database: app/console

Generating forms with Symfony 2.8 throws a Twig_Error_Runtime

只愿长相守 提交于 2019-12-19 05:04:22
问题 Since the last LTS version of Symfony was released few days ago (30.11.2015) I started playing with it. Unfortunately I can't generate a CRUD with write actions with the same code that works fine in Symfony 2.7.7. First I create a new Symfony project using the bash under Linux Mint 17.2: symfony new tasks lts The new directory tasks gets created with a new Symfony 2.8.0 project inside. After adapting the database credentials in app/config/parameters.yml I create the database: app/console

Doctrine detaching, caching, and merging

一世执手 提交于 2019-12-18 15:16:10
问题 I'm on Doctrine 2.3. I have the following query: $em->createQuery(' SELECT u, c, p FROM Entities\User u LEFT JOIN u.company c LEFT JOIN u.privilege p WHERE u.id = :id ')->setParameter('id', $identity) I then take that, get the result (which is an array, I just take the first element), and run detach $em->detach($result); . When I go to fetch from the cache (using Doctrine's APC cache driver), I do: $cacheDriver = new \Doctrine\Common\Cache\ApcCache(); if($cacheDriver->contains($cacheId)) {

symfony2 doctrine allow null values?

人盡茶涼 提交于 2019-12-18 13:53:11
问题 So, I'm still REALLY new to symfony but i'm learning quickly... I created an entity and a crud (i forget how I did it actually but it was via the command line).. The entity was created with this in it: namespace Ecs\CrmBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * Ecs\CrmBundle\Entity\TimeClock */ class TimeClock { /** * @var integer $id */ private $id; /** * @var datetime $in1 */ private $in1; /** * @var datetime $out1 */ private $out1; /** * @var datetime $in2 */ private $in2; /** *

Symfony2 FOSElasticaBundle update index for all entities related to the entity updated

守給你的承諾、 提交于 2019-12-18 12:21:05
问题 I'm using FOSElasticaBundle and Doctrine in my project, and my code works for the selective index update using the Doctrine lifecycle events. The issue I come up against is if I an update a related entity separately. For example a person may be related to a company through a manytomany relationship. If I update the company name through company entity directly, then indexes for the person related to the company will be out of date and still relate to the company's old name. I'm a bit lost as