Comments (7)
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
from language-php.
@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.
from language-php.
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:-)
from language-php.
Wrong colours:
Correct colour:
from language-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();
?>
from language-php.
@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):
from language-php.
@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!
from language-php.
Related Issues (20)
- PHP 8.1
- Function name after newline not classified correctly HOT 1
- Tokenisation of psalm array types HOT 19
- i am unable to download packages that will me code php on atom editor. please i need help.
- Colour formatting gets confused due in specific situations with comment lines and another string containing lots of commas HOT 1
- after this line the rest of the text/code is not formated
- Can't install the latest package version 0.48 HOT 1
- Is this still maintained? HOT 4
- When SQL used within a PHP string, interpolated PHP variables remain unstyled
- Support enum keyword HOT 1
- PHP syntax highlighting does not correctly detect end of string HOT 1
- Interpolation brace style HOT 5
- Curly braces inside HTML inside HEREDOC are marked red
- PHP 8.2
- SQL syntax highlighting with leading line break
- DATE_RFC7231 constant missing HOT 1
- filter_var() Constant missing HOT 1
- php doc types not highlighted HOT 1
- Fork
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from language-php.