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:
R0ck3n
2025-09-08 02:37:42 +02:00
committed by GitHub
parent 686de5271a
commit 6334fa5bea
3 changed files with 56 additions and 0 deletions

View File

@@ -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
}
}