Author: david
Date: Fri May 4 12:19:29 2012
New Revision: 11635
Log:
Copy DSN parsing from
http://trac.symfony-project.org/browser/plugins/sfMySQLDumpPlugin/lib/task/mysql/sfMySQLDumpTask.class.php
Modified:
trunk/lib/task/migrate/arUpgradeSqlTask.class.php
Modified: trunk/lib/task/migrate/arUpgradeSqlTask.class.php
==============================================================================
--- trunk/lib/task/migrate/arUpgradeSqlTask.class.php Fri May 4 12:05:52
2012 (r11634)
+++ trunk/lib/task/migrate/arUpgradeSqlTask.class.php Fri May 4 12:19:29
2012 (r11635)
@@ -97,7 +97,7 @@
// Attempt to backup database (MySQL only)
$backupName = $this->backupDatabase($database);
- // Confirm update
+ // Warn user to backup database manually, if backup failed
if (!isset($backupName) && !$this->askConfirmation(array(
'WARNING: Could not back-up your database!',
'Please back-up your database manually before you proceed.',
@@ -111,9 +111,8 @@
return 1;
}
- $this->logSection('upgrade-sql', sprintf('Upgrading from version %s',
$this->initialVersion));
-
// TODO Do upgrade
+ $this->logSection('upgrade-sql', sprintf('Upgrading from version %s',
$this->initialVersion));
}
protected function getInitialVersion()
@@ -128,26 +127,32 @@
protected function parseDsn($dsn)
{
$params = array(
- 'prefix' => null,
- 'dbname' => null,
'host' => 'localhost',
'port' => '3307');
- //$dsn = 'mysql:dbname=foo';
-
- // Requires a prefix and dbname
- if (!preg_match('/^(\w+):(.*)$/', $dsn, $matches) || !isset($matches[2]))
+ // Require a prefix
+ if (!preg_match('/^(\w+):/', $dsn, $matches))
{
return;
}
-
$params['prefix'] = $matches[1];
- foreach (explode(';', $matches[2]) as $tuple)
+ // Require a dbname
+ if (!preg_match('/dbname=(\w+)/', $dsn, $matches))
{
- list($name,$value) = explode('=', $tuple);
+ return;
+ }
+ $params['dbname'] = $matches[1];
- $params[$name] = $value;
+ // Optional params (host, port)
+ if (preg_match('/host=([^;]+)/', $dsn, $matches))
+ {
+ $params['host'] = $matches[1];
+ }
+
+ if (preg_match('/port=(\d+)/', $dsn, $matches))
+ {
+ $params['port'] = $matches[1];
}
return $params;
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.