PostgreSQL-For-Wordpress / postgresql-for-wordpress

A maintained fork of https://wordpress.org/plugins/postgresql-for-wordpress/
GNU General Public License v2.0
220 stars 71 forks source link

Implement support for prepared statements #63

Open mattbucci opened 10 months ago

mattbucci commented 10 months ago

Implement the following functions, postgres statements work totally different vs mysqli so we'll need to mock the stmt class and fake the behavior.

function wpsqli_prepare(&$connection, $query)
function wpsqli_stmt_execute($stmt)
function wpsqli_stmt_bind_param($stmt, $types, ...$vars)
function wpsqli_stmt_bind_result($stmt, &...$vars)
function wpsqli_stmt_fetch($stmt)
function wpsqli_stmt_init(&$connection)
function wpsqli_stmt_close($stmt)
function wpsqli_stmt_error($stmt)
function wpsqli_stmt_errno($stmt)
// Prepare a query for execution
$result = pg_prepare($dbconn, "my_query", 'SELECT * FROM shops WHERE name = $1');

// Execute the prepared query.  Note that it is not necessary to escape
// the string "Joe's Widgets" in any way
$result = pg_execute($dbconn, "my_query", array("Joe's Widgets"));

// Execute the same prepared query, this time with a different parameter
$result = pg_execute($dbconn, "my_query", array("Clothes Clothes Clothes"));