Regexp (?P<>) is not supported with preg_replace_callback in older PHP versions

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@947 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2009-07-30 09:25:37 +00:00
parent 7b34625b01
commit 175daa360c
2 changed files with 5 additions and 4 deletions

View file

@ -314,7 +314,10 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
function processInput($field, $value, $function = "") {
global $dbh;
$return = $dbh->quote(ereg('date|timestamp', $field["type"]) ? preg_replace_callback('(' . preg_replace('~(\\\\\\$([0-9]))~', '(?P<p\\2>[0-9]+)', preg_quote(lang('$1-$3-$5'))) . ')', 'conversion_date', $value) : $value);
$return = $dbh->quote(ereg('date|timestamp', $field["type"]) && preg_match('(^' . preg_replace('~(\\\\\\$([0-9]))~', '(?P<p\\2>[0-9]+)', preg_quote(lang('$1-$3-$5'))) . ')', $value, $match)
? ($match["p1"] ? $match["p1"] : ($match["p2"] < 70 ? 20 : 19) . $match["p2"]) . "-$match[p3]$match[p4]-$match[p5]$match[p6]"
: $value
);
if (!ereg('varchar|text', $field["type"]) && $field["full_type"] != "tinyint(1)" && !strlen($value)) {
$return = "NULL";
} elseif (ereg('date|time', $field["type"]) && $value == "CURRENT_TIMESTAMP") {

View file

@ -1,4 +1,2 @@
<?php
function conversion_date($match) {
return ($match["p1"] ? $match["p1"] : ($match["p2"] < 70 ? 20 : 19) . $match["p2"]) . "-$match[p3]$match[p4]-$match[p5]$match[p6]";
}