mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-08 00:52:01 +01:00
NEW: Add prepare() method to DoliDB class (rebuild) (#35249)
* feat:prepared sql for mysqli and postgres * refactor:remove whitespace * Update DoliDB.class.php --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
@@ -1512,4 +1512,23 @@ class DoliDBPgsql extends DoliDB
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare a SQL statement for execution (PostgreSQL prepared statement)
|
||||
*
|
||||
* @param string $sql The SQL query to prepare
|
||||
* @return string|false The name of the prepared statement on success, or false on failure
|
||||
*/
|
||||
public function prepare($sql)
|
||||
{
|
||||
$stmtname = uniqid('dolipgstmt_'); // Generate a unique identifier for the statement
|
||||
|
||||
$result = pg_prepare($this->db, $stmtname, $sql);
|
||||
if (!$result) {
|
||||
$this->lasterror = pg_last_error($this->db);
|
||||
return false;
|
||||
}
|
||||
|
||||
return $stmtname; // We just return the name of the prepared statement
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user