Insert line break in SQL SERVER from PHP

0

I execute a SQL SERVER statement from PHP, and I need you to have a line break, since the SQL SERVER system requires them.

PHP code:

$QueryTable = "IF NOT EXISTS (SELECT * FROM sysobjects WHERE 
name='$NombreTabla' AND xtype='U') CREATE TABLE $NombreTabla ( $Columnas ) GO";

The SQL SERVER requires that I insert line breaks once the conditional is finished, and once the statement that creates the table is finished.

This is what I'm looking for:

IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='$NombreTabla' 
AND xtype='U')
CREATE TABLE $NombreTabla ( $Columnas ) 
GO"

What would be the correct way to write my PHP code? Thank you very much, and sorry for the editorial.

    
asked by Gabriel Bellome 12.11.2018 в 19:32
source

1 answer

0

Ah PHP is not interested in how you use the string. Then you can try with the following:

  • Manual (you enter spaces and jumps)
  • $QueryTable = "IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='$NombreTabla'                                                        
    AND xtype='U')                                                                  
    CREATE TABLE $NombreTabla ( $Columnas )                                           
    GO";
    

    It is not practical but you can apply it.

  • Chains and points
  • $QueryTable = "IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='$NombreTabla'".                                                        
    "AND xtype='U')    ".                                                              
    "CREATE TABLE $NombreTabla ( $Columnas ) ".                                          
    "GO";
    
  • Using the escape operators:
  • $QueryTable = "IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='$NombreTabla' AND xtype='U')\n CREATE TABLE $NombreTabla ( $Columnas )\n GO";
    

    The 3 is what I use, use the one you like the most.

    Luck.

        
    answered by 12.11.2018 / 19:51
    source