Search code examples
phpmysqlinnodbcase-sensitive

PHP MySQL InnoDB Unix Windows case sensitive table names


The problem is that deployment MySQL DB is on Linus, and development MySQL DB on Windows. DB is InnoDB. So arose the problem with case-sensitive names of tables. I found solution like:

function getTableName($table_name){
    $query="select TABLE_NAME from `information_schema`.`TABLES` where table_name
     like '%$table_name%' ";
    $result=mysql_query($query,$this->connection);
    $err_number=mysql_errno($this->connection);

    if (!$err_number){
        $num_rows = mysql_num_rows($result);
        if ($num_rows==1){
            $row = mysql_fetch_assoc($result);
            return $row["TABLE_NAME"];
        }else {
            return "";
        }

    }else {
        return "";
    }
}

So name it have be indipendant from type of OS. But may be exist options of MySQL to do the same?


Solution

  • use the lower_case_table_names option