简体   繁体   中英

Is there PHP mysql_real_escape_string for postgresql?

Is there PHP mysql_real_escape_string for postgresql? if yes then how ? please Give the Examples? & also the work of this string

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.

Use pg_query_params() :

<?php    
$result = pg_query_params(
      $dbconn, // database connection
      'SELECT * FROM foo WHERE bar = $1 AND baz = $2', // query using placeholders
      array('value 1','value 2') // all values for the placeholders in a single array
    );
?>

Save and very eary to use.

你有pg_escape_stringpg_escape_bytea可用。

PG转义文字可以提供类似的功能: https : //www.php.net/manual/zh/function.pg-escape-literal.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM