Skip to content

Commit

Permalink
Merge pull request EC-CUBE#174 from nanasess/improve/mysql8
Browse files Browse the repository at this point in the history
MySQL8 対応
  • Loading branch information
ryo-endo committed Oct 25, 2017
2 parents aeb3e97 + aff1677 commit 5b1f4c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 11 additions & 1 deletion data/class/db/dbfactory/SC_DB_DBFactory_MYSQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public function sfChangeMySQL($sql)
$sql = $this->sfChangeTrunc($sql);
// ARRAY_TO_STRINGをGROUP_CONCATに変換する
$sql = $this->sfChangeArrayToString($sql);

// rank に引用符をつける
$sql = $this->sfChangeReservedWords($sql);
return $sql;
}

Expand Down Expand Up @@ -342,6 +343,15 @@ public function sfGetCreateIndexDefinition($table, $name, $definition)
return $definition;
}

/**
* 予約語に引用符を付与する.
*/
public function sfChangeReservedWords($sql)
{
$changesql = preg_replace('/(^|[^\w])RANK([^\w]|$)/i', '$1`RANK`$2', $sql);
return $changesql;
}

/**
* 擬似表を表すSQL文(FROM 句)を取得する
*
Expand Down
5 changes: 5 additions & 0 deletions html/install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,11 @@ function lfExecuteSQL($filepath, $arrDsn, $disp_err = true)
foreach ($sql_split as $key => $val) {
SC_Utils::sfFlush(true);
if (trim($val) != '') {
if ($arrDsn['phptype'] === 'mysqli') {
// rank は予約語なので MySQL8 から引用符をつけないとエラーになる
$dbFactory = SC_DB_DBFactory_Ex::getInstance($arrDsn['phptype']);
$val = $dbFactory->sfChangeReservedWords($val);
}
$ret = $objDB->query($val);
if (PEAR::isError($ret) && $disp_err) {
$arrErr['all'] = '>> ' . $ret->message . '<br />';
Expand Down

0 comments on commit 5b1f4c0

Please sign in to comment.