doctrine

Symfony2 exception when trying to embed a collection of forms

别来无恙 提交于 2019-12-12 04:51:29
问题 A continuation of this question: I'm trying to embed a collection of forms as described in the official docs here. Unfortunately, I'm getting the following exception: The form's view data is expected to be an instance of class Acme\SiteBundle\Entity\BlogPost, but is a(n) array. You can avoid this error by setting the "data_class" option to null or by adding a view transformer that transforms a(n) array to an instance of Acme\SiteBundle\Entity\BlogPost. Which is odd, as I believe I followed

Case not work in doctrine query builder where clause

假装没事ソ 提交于 2019-12-12 04:48:21
问题 I am facing issue with mysql CASE in where clause of doctrine, $rides_q1 = $em->getRepository('IRRideBundle:Ride'); $query = $rides_q1->createQueryBuilder('a') ->where('(CASE WHEN a.ephemeral = 1 THEN a.date_beginning < NOW() AND a.date_ending > NOW()ELSE a.ephemeral = 0 END) AND a.active = 1 AND a.status = 5') ->getQuery(); $ridesQuery = $query->execute(); **[Syntax Error] line 0, col 93: Error: Expected Doctrine\ORM\Query\Lexer::T_ELSE, got '<'** [2/2] QueryException: [Syntax Error] line 0,

How to add correctly a parameter without errors in swagger zircote doctrine

試著忘記壹切 提交于 2019-12-12 04:36:32
问题 i'm using swagger for the first time and the code below results in an "Not a valid parameter definition" error. /** * @SWG\Post( * path="/pub/user/login", * summary="Login", * tags={"User"}, * @SWG\Parameter( * name="phone", * in="formData", * description="The phone from the database", * required=true, * type="string" * ), * @SWG\Parameter( * name="token", * in="formData", * description="The token for this device and phone", * required=true, * type="string" * ), * @SWG\Response( * response

Symofny2 n-m relationship with extra field

本小妞迷上赌 提交于 2019-12-12 04:34:23
问题 I have two tables (test and question) and the middle table (n-m). In this point all works fine. But now, I need to put extra information in the (n-m) table, the order of this question in this test I need this: id | test_id | question_id | order 1 | 1 | 1 | 3 2 | 1 | 2 | 2 3 | 1 | 3 | 1 4 | 1 | 4 | 4 All these relationship have made with doctrine annotation... Test Entity /** * @ORM\ManyToMany(targetEntity="Question", inversedBy="tests") */ private $questions; Question Entity /** * @ORM

How can you/Is it feasible to override Doctrine_Connection in Symfony?

徘徊边缘 提交于 2019-12-12 04:33:49
问题 The university servers I'm currently working on lack PDO drivers, hence I've had to re-implement PDO & it's respective MySQL class to allow doctrine to connect to a MySQL database. This is all well and good (or as well as a PHP implementation of PDO can go) and obviously if uni didn't have PDO at all this would all just work. However, since they have PDO but no drivers , this means I can't re-instantiate PDO and have therefore called it _PDO. This change means that Doctrine_Connection has to

Doctrines automatically aborted in Symfony

萝らか妹 提交于 2019-12-12 04:20:57
问题 I am currently following the symfony-tutorials of Leanna Pelham and Ryan Weaver, and i quickly ran into some problems. I am struggling with the "doctrine:generate" commands, both entities and cruds. This happens when I type in "php app/console doctrine:generate:entity": doctrine:generate:entity This happens when I type in "php app/console doctrine:generate:crud": doctrine:generate:crud I have tried to google this, but couldn't find anything. First i thought a button was jammed up, and that's

Abstract repository and @Entity annotation inheritance

可紊 提交于 2019-12-12 04:06:17
问题 I implement a custom EntityRepository in a Symfony2 application. I have an AbstractEntity (used as parent of some entities) : /** * Abstract Entity. * * @ORM\Entity(repositoryClass="App\Util\Entity\AbstractRepository") */ abstract class AbstractEntity { /** * Get id. * * @return int */ public function getId() { return $this->id; } // ... } The custom EntityRepository : /** * Abstract Repository. */ class AbstractRepository extends Doctrine\ORM\EntityRepository { /** * Handles resource not

How Symfony and Doctrine fetches associations and related entities

大兔子大兔子 提交于 2019-12-12 03:58:40
问题 I cracked my head trying to realize how Symfony and Doctrine fetch associated entities. Lets imagine: i have several associated entities: Company (ManyToOne to City) City (ManyToOne to Region, OneToMany to Company) Region (ManyToOne to Country, OneToMany to City) Country (OneToMany to Region) When i render Company form i create Form Event Listener (on PRE_SET_DATA) that inserts Region and Country selectboxes to this form. The values in these fields must be set according to associated Region.

DQL Doctrine query translation

空扰寡人 提交于 2019-12-12 03:56:45
问题 I have my scores table where I have multiple scores for 1 user. What I am trying to do is to select all highest scores for each user. I am trying to do the fallowing in Doctrine DQL: SELECT * FROM scores s1 LEFT OUTER JOIN scores s2 ON s1.user_id = s2.user_id AND ((s1.score < s2.score) OR (s1.score = s2.score AND s1.date_added < s2.date_added)) WHERE s2.score IS NULL ORDER BY s1.score DESC LIMIT 10 My current state is: $rowQuery = $this->getEntityManager()->createQuery(' SELECT s1 FROM

Retrieving doctrine data from sfDoctrinePager object !

孤人 提交于 2019-12-12 03:49:50
问题 I am facing some issues while retrieving data from a doctrine pager object! Let me describe it below: This is my pager query: $pager = new sfDoctrinePager('sfGuardUser', '5'); $q = Doctrine_Query::create() ->select('u.id, u.username, p.org_name, g.name, l.status') ->from('sfGuardUser u') ->leftJoin('u.Profile p') ->leftJoin('u.Groups g') ->leftJoin('u.LicensedVendors l') ->where('g.name = \'client\''); $pager->setQuery($q); $pager->setPage($request->getParameter('page', 1)); $pager->init();