Add the function ExecSqlParam
This commit is contained in:
parent
118da55637
commit
56f4b4fec1
1 changed files with 27 additions and 0 deletions
|
|
@ -142,6 +142,33 @@ function ExecSql($p_connection, $p_string) {
|
|||
ob_flush();
|
||||
return $ret;
|
||||
|
||||
}
|
||||
/*!
|
||||
* \brief send a sql string to the database using the function
|
||||
* pg_query_params. Useful for avoiding the problem with the quotes
|
||||
* and to execute several times the same command
|
||||
* \param $p_connection db connection
|
||||
* \param $p_string sql string
|
||||
* \param $p_array array containing the value
|
||||
* \return false if error otherwise true
|
||||
*/
|
||||
function ExecSqlParam($p_connection, $p_string,$p_array) {
|
||||
echo_debug('postgres.php',__LINE__,"SQL = $p_string");
|
||||
echo_debug('postgres.php',__LINE__,$p_array);
|
||||
// probl. with Ubuntu & UTF8
|
||||
//----
|
||||
|
||||
pg_set_client_encoding($p_connection,'latin1');
|
||||
ob_start();
|
||||
$ret=pg_query_params($p_connection,$p_string,$p_array);
|
||||
if ( ! $ret ) {
|
||||
ob_clean();
|
||||
$r=$string."array ".var_export($p_array,TRUE);
|
||||
throw new Exception (" SQL ERROR $r",1);
|
||||
}
|
||||
ob_flush();
|
||||
return $ret;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue