diff options
author | Robin Appelman <icewind1991@gmail.com> | 2012-01-08 14:07:12 +0100 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2012-01-08 14:07:12 +0100 |
commit | ae711168c3308e013c0d24cc7f832ff91077e911 (patch) | |
tree | 4171e4c2ed907c39a954998a7bfed4b714028e80 /lib | |
parent | 4d1ed7e05f5efc589b7fb6031661ccda496cee76 (diff) | |
download | nextcloud-server-ae711168c3308e013c0d24cc7f832ff91077e911.tar.gz nextcloud-server-ae711168c3308e013c0d24cc7f832ff91077e911.zip |
improve detection for mysql databases
Diffstat (limited to 'lib')
-rw-r--r-- | lib/setup.php | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/setup.php b/lib/setup.php index d454c17599d..a65dc9453c2 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -103,7 +103,7 @@ class OC_Setup { //use the admin login data for the new database user //add prefix to the mysql user name to prevent collissions - $dbusername=substr('oc_mysql_'.$username,0,16); + $dbusername=substr('oc_'.$username,0,16); //hash the password so we don't need to store the admin config in the config file $dbpassword=md5(time().$password); @@ -124,9 +124,12 @@ class OC_Setup { } //fill the database if needed - $query="SELECT * FROM $dbname.{$dbtableprefix}users"; + $query="select count(*) from information_schema.tables where table_schema='$dbname' AND table_name = '{$dbtableprefix}users';"; $result = mysql_query($query,$connection); - if(!$result) { + if($result){ + $row=mysql_fetch_row($result); + } + if(!$result or $row[0]==0) { OC_DB::createDbFromStructure('db_structure.xml'); } mysql_close($connection); |