php - Symfony 2 Doctrine LEFT JOIN -
In DB I have 3 tables: task_estimation_fields:
create tab 'work_stimation_filand' (`id 'int (11) faucet atonement,` name' varchar (45) null, primary key (`id `), Unique key 'name_tip' (` name ')) engine = indodebi;
task_estimations:
CREATE TABLE `task_estimations` (` id` integer (11) No NULL AUTO_INCREMENT, `task_id` integer (11) No NULL, `Task_estimation_field_id` integer (11) not NULL,` description` bob, `summary` bob,` effort` integer (11) not null, `created_at` datetime not null,` created_by` integer (11) null, primary key `Id`), key`g1` (` task_id`), key`g2` (`created_by`), key` g3` (` task_estimation_field_id`), barrier 'g1` foreign key (`task_id`) reference` tasks Any action from DELETE (`id`) update, block 'g2` foreign key (` created_by`) Any action by updating the reference `users` (` id`), no action on the 'g3` foreign key no action DELETE (`Task_estimation_field_id`) reference` work_stimation_flames` (`id`) Update any action No action) engine = InnoDB;
Functions:
create table 'work' (`id`inte (11) faucet auacrmant,` ACACAIID` (11) tap, `status_id `Integer (11) No NULL,` prioryty_id` integer (11) No NULL, `title` varchar (45) No NULL,` description` longblob, primary key (`id`)) engine = InnoDB;
$ php app / console principle: mapping: import - force acme blogbundle xml $ php app /
console theory: mapping: convert to annotations ./ Src $ php App / Console Principle: Generate: Institutions AcmeBlogBundle
and I want to get the result of this query:
select * tef left from task_estimation_fields Task_estimations to JOIN (tef.id = te.task_estimation_field_id and te.task_id = 1)
I am using Symphony 2.4.3 and I have created the following code:
$ estimations = $ this- & Gt; GetDoctrine () - & gt; GetManager () - & gt; CreateQueryBuilder () - & gt; Select ('tef, te') - & gt; ('SynapthsisSpecBundle: TaskEstimationFields', 'tef') - & gt; LeftJoin ('SynapthsisSpecBundle: TaskEstimations', 'To', 'with', 'tef.id = te.task_estimation_field_id and te.task_id =: id') - & gt; Setp armor ('id', id =) - & gt; GetQuery () - & gt; GetResult ();
The problem is that I am getting the following error:
[semantic error] line 0, call near 'task_estimation_field_id' 133: error: class There is no field or association named work_stimation_field_id
in synthesis \ SpecBundle \ Entity \ TaskEstimations and it is true that there is no such field in the unit, but it contains:
/ * * * @var \ Synapthsis \ SpecBundle \ unit \ TaskEstimationFields * * @ORM \ ManyToOne (targetEntity = "Synapthsis \ SpecBundle \ unit \ TaskEstimationFields") * @ORM \ JoinColumns ({* @ORM \ JoinColumn ( Name = "task_ Estimation_field_id ", ReferencedColumnName =" id ") *}) * / Private $ workEstimationField;
Includes a relationship.
When I remove the query builder:
$ estimations = $ this- & gt; GetDoctrine () - & gt; GetManager () - & gt; CreateQueryBuilder () - & gt; Selection ('tef, te') - & gt; From ('SynapthsisSpecBundle: TaskEstimationFields', 'tef') - & gt; LeftJoin ('SynapthsisSpecBundle: TaskEstimations', 'Te', 'Weed', 'T. Task_IDID =: ID') - & gt; Setpayeter ('id', $ id) - & gt; GetQuery () - & gt; GetResult (); I'm getting: [semantic error] line 0, beside 'work_id =: i' 124: error: class synthesis \
This is also true because it is covered in the unit:
/ * * @or \ Synapsithsis \ SpecBundle \ unit \ function * * @ORM \ ManyToOne (targetEntity = "Synapthsis \ SpecBundle \ unit \ work") * @ORM \ JoinColumns ({* @ORM \ JoinColumn (name = "task_id" Referenced ColumnName = "id") *}) * / private $ jobs;
How can the results be required? How to print those results in tiga?
In the DQL query you need to use association name Column name .
In your case, you need to use te.taskEstimationField
instead of te.task_estimation_field_id
I / code> and te.task
. te.task_id
instead of