mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-07-30 01:37:13 +02:00
Convert MySQL RAND() to PostgreSQL RANDOM()
These functions are compatible, with the exception that MySQL RAND() optionally takes a seed argument. If future queries require seed support, a call to PostgreSQL SETSEED() can be added. Fixes: #12 Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
This commit is contained in:
@ -299,6 +299,10 @@
|
||||
|
||||
$pattern = '/GROUP_CONCAT\(([^()]*(\(((?>[^()]+)|(?-2))*\))?[^()]*)\)/x';
|
||||
$sql = preg_replace( $pattern, "string_agg($1, ',')", $sql);
|
||||
|
||||
// Convert MySQL RAND function to PostgreSQL RANDOM function
|
||||
$pattern = '/RAND[ ]*\([ ]*\)/';
|
||||
$sql = preg_replace( $pattern, 'RANDOM()', $sql);
|
||||
|
||||
// UNIX_TIMESTAMP in MYSQL returns an integer
|
||||
$pattern = '/UNIX_TIMESTAMP\(([^\)]+)\)/';
|
||||
|
Reference in New Issue
Block a user