'or' in PHP Postgres requests

  • When should you use a character in PHP pg requests?
  • When should you use the "character in PHP pg requests?

This question is based on this answer .

+3
source share
2 answers

In a PostgreSQL query, you should use '

When you create a request in PHP, you can use "or"

"select * from table where id = 'me'"

or

'select * from table where id = \'me\''
+2
source

Postgres string literals are defined using single quotes. Double quotes are used around identifiers. So the following query is valid.

SELECT "id", "name" FROM my_table WHERE "name" = 'Brian' 

, , , "vs double quote" PHP, postgres-.

, , , , .

$my_var = "noob";

echo "This is a test string, $my_var\nGot it?";
>> This is a test string, noob
>> Got it?

echo 'This is a test string, $my_var\nGot it?';
>> This is a test string, $my_var\nGot it?
+4

Source: https://habr.com/ru/post/1716386/


All Articles