problem with ( in qoutes
Opened this issue · 7 comments
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Reproduced the problem in Safe Mode: https://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode
- Followed all applicable steps in the debugging guide: https://flight-manual.atom.io/hacking-atom/sections/debugging/
- Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq
- Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom
- Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages
Description
Steps to Reproduce
Expected behavior:
Actual behavior:
Reproduces how often:
Versions
Additional Information
After this code the rest of the code is not formatted in correct colours: $sql = $sql . " AND ($key LIKE '" . $valuex . "'";
It is the ( making the wrong formatting of text colours. If i remove the ( then coulors are correct.
Is there anybody who can fix this bug..... Thanks in advance:-)
This is known issue and rather hard to fix. Try to avoid incomplete sql syntax, for example:
$value = ['testA', 'testB'];
if(isset($value) AND count($value)){
$search = array_map(fn($valuex) => "{$key} LIKE '%{$valuex}%'", $value);
$search = implode(' OR ', $search);
} else {
$search = "{$key} = '0'";
}
$sql .= " AND ({$search})";
Even better would be to use prepared statements to prevent some attacks using insecure variables https://www.php.net/manual/en/mysqli.quickstart.prepared-statements.php
This is an issue even if the query itself is unbroken.
See this example, where everything after the $query variable loses the syntax highlighting
<?php
$query = "SELECT
`users`.`total_review` AS `total`,
`users`.`negative_review`,
`note`.`satisfaction`,
`note`.`recommendation` AS `question_6`
FROM (
SELECT
`exam_note_users`.`satisfaction`,
`exam_note_users`.`recommendation`
FROM `exam_note_users`
WHERE
`exam_note_users`.`question_id` IS NULL
AND `exam_note_users`.`category_id` IS NULL
AND `exam_note_users`.`company_id`=:company_id
) AS `note`,
(
SELECT
`exam_users`.`total_review`,
`exam_users`.`negative_review`
FROM `exam_users`
WHERE
AND `exam_users`.`company_id`=:company_id
) AS `users`";
$statementAggregation = $database->prepare($query);
$statementAggregation->bindValue(":company_id", $rowReportCompany["company_id"], PDO::PARAM_INT);
$statementAggregation->execute();
$rowAggregation = $statementAggregation->fetch();
?>
Taking the last parentheses and making it it's own string gets the syntax highlighting back
<?php
$query = "SELECT
`users`.`total_review` AS `total`,
`users`.`negative_review`,
`note`.`satisfaction`,
`note`.`recommendation` AS `question_6`
FROM (
SELECT
`exam_note_users`.`satisfaction`,
`exam_note_users`.`recommendation`
FROM `exam_note_users`
WHERE
`exam_note_users`.`question_id` IS NULL
AND `exam_note_users`.`category_id` IS NULL
AND `exam_note_users`.`company_id`=:company_id
) AS `note`,
(
SELECT
`exam_users`.`total_review`,
`exam_users`.`negative_review`
FROM `exam_users`
WHERE
AND `exam_users`.`company_id`=:company_id";
$query .=") AS `users`";
$statementAggregation = $database->prepare($query);
$statementAggregation->bindValue(":company_id", $rowReportCompany["company_id"], PDO::PARAM_INT);
$statementAggregation->execute();
$rowAggregation = $statementAggregation->fetch();
?>
@echantigny I'm unable to reproduce your issue. Can you provide screenshot showing the problem? Which version of atom are you using? Which version of language-php?
That's how your code looks like on my end (don't mind whitespace symbols):
@KapitanOczywisty I just realised that the github issue I was looking at for VSCode sent me here, on the Atom project.
If it really is linked projects, this is what I have installed with PHP Intelephense. Otherwise, well... you can ignore my messages. :)
Version: 1.63.2 (user setup)
Commit: 899d46d82c4c95423fb7e10e68eba52050e30ba3
Date: 2021-12-15T09:40:02.816Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19043
And as of this morning (VS Code updated last night), it looks like this is fixed now.
Sorry!
@echantigny This is the right place, VS Code is using syntax from this repository and Intelephense doesn't provide syntax highlighting.
Last update was a month ago, so there might be something wrong if VS Code updated yesterday. I've also tested your code in VS Code yesterday and it was fine. Let me know if something similar happens again.