PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 16, 2022

[FIXED] DoctrineSelect with Variable

 January 16, 2022     doctrine, php, query-builder, sql, symfony     No comments   

Issue

I'm trying something like this with doctrine:

SELECT 
    @myprice := cp.price,
    @compPrice1 := (SELECT cpt1.price FROM competitor_product AS cpt1 
                    WHERE cpt1.product_id = cp.product) as compPrice1 
    @compPrice1 / @myprice  AS price_diff
FROM
    customer_product AS cp 
WHERE 
    customer_id = 1;

My code until then:

[my code until then]1

How can I set variable for use in calculate column?

I've been looking for but found nothing about


Solution

I don't think this is possible with Doctrine Query builder. I would suggest use Doctrine Native Query or Raw SQL queries.



Answered By - Mohamed Sharfaz Sairaz
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing