dql

Access to many-to-many relation in array format, symfony2

拟墨画扇 提交于 2019-12-12 02:26:14
问题 in symfony we can access many-to-many relations with getter functions which return objects of ArrayCollection type. for example for getting Alex's students we can call $alex->getStudens() , then i have access to ale's studens object. now my question is how i can access alex's students id's in array, for example by calling $alex->getStudentsIds() it returns {1,5,7,12,..} , which are his students's ids. 回答1: precisely how you wrote it, you add another function in the entity public function

How to look for an entity's self referenced entity in my Doctrine search?

我的未来我决定 提交于 2019-12-12 02:18:04
问题 When looking at the User entity, you can see its a manytomany self referencing relation. A user has many friends who are users themselves. How do I make this exact same search in within a user's friends? (in this query, I'm only looking for users who fill those conditions, but I would like to perform it in a $user friends) $qb = $this->getEntityManager()->createQueryBuilder(); $qb->select( 'USER', '' ) ->from( 'Entity\User', 'USER' ) ->innerJoin( 'USER.eventNotified' ) ->where( $qb->expr()-

doctrine 2 where condition without comparison

守給你的承諾、 提交于 2019-12-12 02:04:01
问题 I have written a custom function for the DQL: <?php namespace Bundle\DQL\Functions; use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Query\Parser; /** * "DATE_COMPARE" "(" ArithmeticPrimary "," ComparisonOperator "," ArithmeticPrimary ")" */ class DateCompareFunction extends FunctionNode { public $date1; public $date2; public $operator; /** * @override * @param SqlWalker $sqlWalker * @return string * @throws

Is there a way or a plugin to configure SQL Dialects as DQL in PhpStorm?

眉间皱痕 提交于 2019-12-11 16:39:19
问题 In PhpStorm, I can change global, project or directories settings with existing SQL Dialects, but is there a way to configure SQL Dialects as Symfony/DQL in PhpStorm or a way to detect that App:Panel is a valid entity, not a table? ( App:Panel table name is te_panel ) I read this answer which explains that we have to add a Java plugin, because it's currently not possible to add a new SQL Dialect on PhpStorm. As example, this is an error that PhpStorm is throwing: The : between App and Panel

Using RAND() function from SQL with Doctrine2

北城余情 提交于 2019-12-11 11:19:59
问题 I've been stuck with this for about 10 hours I need to use this query (an optimized version of ORDER BY RAND) public function findAllRandom() { return $this->getEntityManager() ->createQuery( 'SELECT p FROM GabrielUploadBundle:Image p WHERE RAND() < 0.0001 ORDER BY RAND() LIMIT 20') ->getResult(); } And of course since I'm using DQL I need to implement the RAND() function <?php namespace Gabriel\UploadBundle\DoctrineFunctions; use Doctrine\ORM\Query\Lexer; /** * RandFunction ::= "RAND" "(" ")

SQL Multiple sorting and grouping

↘锁芯ラ 提交于 2019-12-11 08:53:51
问题 EDIT: I'm using DQL I'm looking for help with an SQL query. My table has a list of movies, each with a title, seriesName and seriesNumber. Is it possible to order them so the Titles are listed A-Z, but when a series occurs, that series is grouped together, with the seriesName being placed alphabetically as if it were inthe movieTitle column, and the entries in a series ordered by seriesNumber. Bad explanation, but basically what I want is this: MovieTitle SeriesName SeriesNumber Blade Runner

retrieve a row of data from documentum via DQL

╄→尐↘猪︶ㄣ 提交于 2019-12-11 04:49:39
问题 I have a list of users in my list view which is populated by retrieving data from documentum . If I click on any row of this least (each row represent one user) I should be able to see all of their information listed down .( This is my problem ) public void selectedItemFromListView(){ selected = lwAllUserGrp.getSelectionModel().getSelectedItem(); System.out.println(selected); String query =" select * from dm_user where user_name = '@aclName'" ; String test = query.replace("@aclname", selected

Symfony2/Doctrine: SQL to DQL for a querybuilder in a repository to make a search form

↘锁芯ラ 提交于 2019-12-11 04:17:26
问题 In my project with Symfony, I need to make a search form with multicriteria. I have a select for the entity Parc, a select for the entity Typesactivite and an input text for Ensembles. I have this SQL request: SELECT distinct e.nom FROM `ensembles` e, `parcsimmobilier` p, `batiments` b, `batiments_typesactivite` bta, `typesactivite` ta WHERE e.parcsimmobilier_id=p.id AND b.ensembles_id=e.id AND bta.batiments_id=b.id AND bta.typesactivite_id = ta.id AND p.nom="Ville de Dijon" AND ta.type=

Symfony 1.4/ Doctrine; n-m relation data cannot be accessed in template (indexSuccess)

ⅰ亾dé卋堺 提交于 2019-12-11 04:09:35
问题 I have a database with 3 tables. It's a simple n-m relationship. Student, Course and StudentHasCourse to handle n-m relationship. I post the schema.yml for reference, but it would not be really necessary. Course: connection: doctrine tableName: course columns: id: type: integer(4) fixed: false unsigned: false primary: true autoincrement: false name: type: string(45) fixed: false unsigned: false primary: false notnull: false autoincrement: false relations: StudentHasCourse: local: id foreign:

Symfony/Doctrine - Twig_Error_Runtime: Catchable Fatal Error: Object of class Doctrine\ORM\PersistentCollection could not be converted to string

大城市里の小女人 提交于 2019-12-11 01:46:40
问题 I have this entity in my symfony project: /** * Batiments * * @ORM\Table(name="batiments") * @ORM\Entity * @ORM\Entity(repositoryClass="MySpace\DatabaseBundle\Repository\BatimentsRepository") */ class Batiments { /** * @var integer * * @ORM\Column(name="id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; /** * @var string * * @ORM\Column(name="nom", type="string", length=150, nullable=true) */ private $nom; /** * @ORM\ManyToOne