From 6587b4085b39b2bac6be3562d7636161c5cb8f24 Mon Sep 17 00:00:00 2001 From: Kevin Locke Date: Sat, 8 Apr 2017 16:20:58 -0600 Subject: [PATCH] Create MySQL-compatible field function on connect Fixes: #8 Signed-off-by: Kevin Locke --- pg4wp/driver_pgsql.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/pg4wp/driver_pgsql.php b/pg4wp/driver_pgsql.php index 24b66a3..d4281b2 100644 --- a/pg4wp/driver_pgsql.php +++ b/pg4wp/driver_pgsql.php @@ -109,6 +109,8 @@ foreach( $GLOBALS['pg4wp_pre_sql'] as $sql2run) wpsql_query( $sql2run); + pg4wp_init($conn); + return $conn; } @@ -573,6 +575,35 @@ return $sql; } + // Database initialization + function pg4wp_init() + { + // Provide (mostly) MySQL-compatible field function + // Note: MySQL accepts heterogeneous argument types. No easy fix. + // Can define version with typed first arg to cover some cases. + // Note: ROW_NUMBER+unnest doesn't guarantee order, but is simple/fast. + // If it breaks, try https://stackoverflow.com/a/8767450 + $result = pg_query(<<