[geeklog-cvs] geeklog: Changed logic for the auto-detect of table prefix to ha...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Wed Jan 7 03:53:36 EST 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/6150014cda16
changeset: 6666:6150014cda16
user:      Dirk Haun <dirk at haun-online.de>
date:      Tue Jan 06 17:32:41 2009 +0100
description:
Changed logic for the auto-detect of table prefix to handle old-style mysqldump backups

diffstat:

1 file changed, 9 insertions(+), 3 deletions(-)
public_html/admin/install/migrate.php |   12 +++++++++---

diffs (29 lines):

diff -r 8817f62abd8a -r 6150014cda16 public_html/admin/install/migrate.php
--- a/public_html/admin/install/migrate.php	Tue Jan 06 16:27:45 2009 +0100
+++ b/public_html/admin/install/migrate.php	Tue Jan 06 17:32:41 2009 +0100
@@ -542,6 +542,7 @@
             // Parse the .sql file to grab the table prefix
             $has_config = false;
             $num_create = 0;
+            $DB['table_prefix'] = '';
 
             $sql_file = @fopen($backup_dir . $backup_file, 'r');
             if (! $sql_file) {
@@ -554,9 +555,14 @@
                     if (preg_match('/CREATE TABLE/i', $line)) {
                         $num_create++;
                         $line = trim($line);
-                        if (strpos($line, 'access`') !== false) {
-                            $DB['table_prefix'] = preg_replace('/^.*`/', '',
-                                    preg_replace('/access`.*$/', '', $line));
+                        if (strpos($line, 'access') !== false) {
+                            $words = explode(' ', $line);
+                            if (count($words) >= 3) {
+                                $table = str_replace('`', '', $words[2]);
+                                if (substr($table, -6) == 'access') {
+                                    $DB['table_prefix'] = substr($table, 0, -6);
+                                }
+                            }
                         } elseif (strpos($line, 'conf_values') !== false) {
                             $has_config = true;
                             break;



More information about the geeklog-cvs mailing list