[Solved] SQL Syntax in PHP code

Hi, 

In my PHP code, I write SQL code like this :

$SQLQuery = " DELETE FROM personnes ";
$SQLQuery .= " WHERE per_id = ".$id." ";

But, PHPStorm detect warning : 'Delete' statement without 'where' clears all data in the table in the first line.

 

I don't want to disable this warning in all the project (!!!).

I don't find to disable this warning for this line (with a @noinspection PhpStatement tag).

Or, perhaps, PHPStorm would like to find SQL requests in an other syntax...

 

So where is the good way ?

 

Thank's for your help

 

F.

0

The warning can be suppressed with /** @noinspection SqlWithoutWhere */ comment.

1

May I suggest you avoid string concatenation altogether, as in this example?

$SQLQuery = "DELETE FROM personnes
    WHERE per_id = $id";

This way PhpStorms understands your query as a whole and you can get a lot of goodies: sensible syntax highlighting and linting, auto-completion, edit fragment...

 

 

 

0

请先登录再写评论。