Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

196
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda