Skip to content

Commit

Permalink
Merge pull request #4145 from vanilla/fix/mysql-remove
Browse files Browse the repository at this point in the history
Replace MySQL with MySQLi for imports
  • Loading branch information
linc committed Aug 26, 2016
2 parents 5b765ee + 501e544 commit 309a67c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -49,6 +49,7 @@ If you professionally run a large community or enterprise forum, our cloud solut
* PHP version 5.3 or newer with `--enable-mbstring`.
* pdo_mysql module must be enabled.
* MySQL 5 or newer.
* If you intend to [Migrate to Vanilla](#migrating-to-vanilla) you will also need PHP with `--with-mysqli`.

Vanilla 2.2 requires PHP 5.3. Running `master` branch requires PHP 5.4, as will future official releases.

Expand Down
19 changes: 9 additions & 10 deletions applications/dashboard/models/class.importmodel.php
Expand Up @@ -1274,24 +1274,23 @@ protected function _LoadTableLocalInfile($Tablename, $Path) {

Gdn::database()->query("truncate table $Tablename;");

$Sql = "load data local infile $Path into table $Tablename
$sql = "load data local infile $Path into table $Tablename
character set utf8
columns terminated by ','
optionally enclosed by '\"'
escaped by '\\\\'
lines terminated by '\\n'
ignore 1 lines";

// We've got to use the mysql_* functions because PDO doesn't support load data local infile well.
$dblink = mysql_connect(c('Database.Host'), c('Database.User'), c('Database.Password'), false, 128);
mysql_select_db(c('Database.Name'), $dblink);
$Result = mysql_query($Sql, $dblink);
if ($Result === false) {
$Ex = new Exception(mysql_error($dblink));
mysql_close($dblink);
throw new $Ex;
// We've got to use the mysqli_* functions because PDO doesn't support load data local infile well.
$mysqli = new mysqli(c('Database.Host'), c('Database.User'), c('Database.Password'), c('Database.Name'), 128);
$result = $mysqli->query($sql);
if ($result === false) {
$ex = new Exception($mysqli->error);
$mysqli->close();
throw new $ex;
}
mysql_close($dblink);
$mysqli->close();
}

/**
Expand Down

0 comments on commit 309a67c

Please sign in to comment.