Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
How to correctly comment a DB query in a PHP application?

I am abslutly new in PHP and probably this is a very trivial question about how to correctly comment a line in a MySql query.

I have a query like this:

$query_hotel= "
    SELECT 
        hotel_name,
        hotel_id,
        room_id,
        ...................................
        ...................................
        ...................................
        FROM (
            ............................................
            ............................................
            )
            WHERE
                ...............................................
            HAVING
                //SUM(rate.price) BETWEEN ".$price_min." AND ".$price_max."
                SUM(rate.price) BETWEEN ".$min_price." AND ".$max_price."

    ................................................................................
    ................................................................................
    ................................................................................

So, as you can see in my code, I have to comment (to disable) this line:

//SUM(rate.price) BETWEEN ".$price_min." AND ".$price_max."

that have to be replaced by this line:

SUM(rate.price) BETWEEN ".$min_price." AND ".$max_price."

I am not sure that using the // at the line start it's correct. I also tried to do:

<!--SUM(rate.price) BETWEEN ".$price_min." AND ".$price_max."-->

but doing in this way my IDE (PHP Storm) is as disabled all but not the PHP variable.

So what is the correct way to do it without remove this line from my code? (I want to keep track of this changes and let it commented in my code)

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

SQL has two kinds of comments. A one-line comment uses the prefix --. You can also create a block comment by surrounding it with /* and */.

MySQL also allows # as a comment prefix, this is an extension to the SQL standard.

$query_hotel= "
    SELECT 
        hotel_name,
        hotel_id,
        room_id,
        ...................................
        ...................................
        ...................................
        FROM (
            ............................................
            ............................................
            )
            WHERE
                ...............................................
            HAVING
                /* SUM(rate.price) BETWEEN ".$price_min." AND ".$price_max." */
                SUM(rate.price) BETWEEN ".$min_price." AND ".$max_price."

    ................................................................................
    ................................................................................
    ................................................................................
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!