Is there PHP mysql_real_escape_string for postgresql? if yes then how ? please Give the Examples? & also the work of this string
PHP provides many functions for working directly with PostgreSQL databases. To connect to PostgreSQL using native functions, follow these steps: Use the following PHP code to connect to PostgreSQL and select a database.
This extension was deprecated in PHP 5.5. 0, and it was removed in PHP 7.0.
PostgreSQL also accepts “escape” string constants, which are an extension to the SQL standard. An escape string constant is specified by writing the letter E (upper or lower case) just before the opening single quote, e.g., E'foo' .
See pg_escape_string
at http://www.php.net/manual/en/function.pg-escape-string.php.
Alternatively you could use prepared statements (pg_prepare) and placeholders ($1
, $2
, etc), and then give the arguments for the query in pg_execute. This would be my preferred way as it's not only cleaner, but also safer in the long run since there's no chance for SQL injections if you always use placeholders in prepared statements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With