Coder Social home page Coder Social logo

problem with ( in qoutes about language-php HOT 7 OPEN

hcn501 avatar hcn501 commented on August 18, 2024
problem with ( in qoutes

from language-php.

Comments (7)

KapitanOczywisty avatar KapitanOczywisty commented on August 18, 2024 2

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.

KapitanOczywisty avatar KapitanOczywisty commented on August 18, 2024 1

@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.

hcn501 avatar hcn501 commented on August 18, 2024

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.

hcn501 avatar hcn501 commented on August 18, 2024

Wrong colours:
Skærmbillede 2021-09-17 kl  18 34 49
Correct colour:
Skærmbillede 2021-09-17 kl  18 37 39

from language-php.

echantigny avatar echantigny commented on August 18, 2024

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.

KapitanOczywisty avatar KapitanOczywisty commented on August 18, 2024

@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):
image

from language-php.

echantigny avatar echantigny commented on August 18, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.