Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda