doctrine

Unable to find Twig template using render method in Symfony 2

好久不见. 提交于 2019-12-24 00:09:31
问题 I am experiencing an issue trying to reference a particular Twig template. I am using the render method that is part of the SF2 main controller, but I clearly not referencing/using it correctly. This is my directory/file structure: /src /AyrshireMinis /CommonBundle /Controller DefaultController.php /Entity Link.php /Resources /views /Default links.html.twig and this is the method called by the router in DefaultContoller.php : /** * @Route("/links", name="ayrshireminis_links") * @Template() */

ORM Solution for really complex queries

半世苍凉 提交于 2019-12-23 23:03:52
问题 Can/should One use any ORM Solution is a Complex Situation like this ? can this even be done with Propel or Doctrine ? at the moment I am using Propel. So I'd be glad If there is Propel solution for it. If I do a direct query with propel what are the suggestion ? SELECT I.*,((I.width*175)/I.height) as relativeWidth FROM (SELECT * FROM Image WHERE owner = 1 LIMIT 5, 10) I order by relativeWidth asc and additionally What is the standard solution for the scenario where one needs to exequte

Deprecated classes warnings in Symfony 5.0.1 console on Windows

こ雲淡風輕ζ 提交于 2019-12-23 22:57:49
问题 After executing php bin\console make:entity (User entity) or php bin\console make:migration i get these warnings in console: 2019-12-13T15:49:53+00:00 [info] User Deprecated: The Doctrine\Common\Persistence\ObjectRepository class is deprecated since doctrine/persistence 1.3 and will be removed in 2.0. Use \Doctrine\Persistence\ObjectRepository instead. 2019-12-13T15:49:53+00:00 [info] User Deprecated: The Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory class is deprecated

Compare two Doctrine_Record objects

为君一笑 提交于 2019-12-23 22:27:56
问题 How do I compare two Doctrine_Record objects to see if they are "equal"? On the domain login I am considering, two objects are equal if they have the same properties values, except the id and the created_at and updated_at fields (a la Timestampable ). 回答1: First idea which comes into my mind is: class User extends Doctrine_Record { public function equals(User $user) { $left = $this->toArray(); $right = $user->toArray(); unset($left['id'], $left['created_at'], $left['updated_at']); unset(

Not finding field in polymorphic association with Doctrine2

蓝咒 提交于 2019-12-23 19:46:34
问题 I have a polymorphic association (Class Table Inheritance) and I need use DQL to query entities of a specific child class wich can be done using "x INSTANCE OF Entity" in WHERE clause. Now I need to put conditions specific for that child class but I get this error: "Class Person has no association named student_field_1" Person = Parent Class Employee = Child class Student = Child class is there any way yo cast of somehow tell Doctrine that the Person is actually a Student and to allow me to

“IN” predicate with Criteria filtering isn't working

本秂侑毒 提交于 2019-12-23 18:11:19
问题 I'm trying to filter a doctrine collection directly with Criteria in order to avoid all collection-loading when I'm searching only for certain elements. public function bar() { $entity = ...; // not useful for the example $property = ...; // not useful for the example but is a getter for a collection $ids = [22, 13]; // just for the sake of this example $criteria = Criteria::create()->where(Criteria::expr()->in("id", $ids)); return $this->foo($entity, $property, $criteria); } public function

Uncaught PHP Exception Doctrine\ORM\ORMException: “Unknown Entity namespace alias 'AppBundle'.”

99封情书 提交于 2019-12-23 17:25:40
问题 I just started my first project with composer and wanted to set up the database and the classes for it. However I'm stuck. I'm getting the above error in the prod.log I followed this tutorial here: http://symfony.com/doc/current/book/doctrine.html I created the database php bin/console doctrine:database:create then wanted to create an entity php bin/console doctrine:generate:entity When asked for the The Entity shortcut name I entered AppBundle:Product and then created the database fields etc

Functional Test - Mock service does not persist in service container

限于喜欢 提交于 2019-12-23 17:16:06
问题 I am hoping someone can shed some light on this issue I am facing. [PROBLEM] I have mocked out doctrine.orm.default_entity_manager service in my functional unit test. I inject this into the client service container so that I do not have to hit my DB during the course of my functional test. For my test that just involve a GET request I am able to verify that the controller I am testing is using my mocked service. However, if I attempt to do a POST request by using the crawler with a form

What is the @var annotation for in a Doctrine entity in Symfony?

偶尔善良 提交于 2019-12-23 16:59:17
问题 Perhaps a silly question but it bugs me that I don't know ... When I create an entity with app/console doctrine:generate:entity it adds an @var annotation to each property. What is @var used for? It obviously indicates the data type but I don't see it mentioned in any documentation and things seems to work whether it's there or not so I just wonder what uses it. 回答1: This is a standard phpdoc comment. It has nothing to do with Doctrine annotations, and they are ignored by Doctrine. They are

Doctrine Query Builder nested orX and andX conditions with join

本秂侑毒 提交于 2019-12-23 14:02:56
问题 I have two entities User and CalendarEvent . My users are attached to a factory, and calendarEvent can be used to know if a user is "loaned" to a different factory of the one he belongs to... My two entities are like this : User : class User extends BaseUser { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @var string * @ORM\Column(name="firstname", type="string", length=255, nullable=true) */ private $firstname; /** * @var string *