Monday 8 January 2018

php - mysql case sensitive table names in queries

itemprop="text">

I have php code where first letter of
database table names is in capital letter every where but table names in database are in
lowercase.




What global setting should
I use so that no need to change in every code file for making table names in same case
as in database.


itemprop="text">
class="normal">Answer



MySQL
metadata is case sensitive by default on Linux. That is if you have a table my_table, in
lower case, then



select * from
my_table


will succeed
while




select * from
MY_TABLE


will fail
with some sort of table doesn't exist
message.



If you want both statements to succeed,
you need to put the following line
lower_case_table_names = 1
in
your /etc/my.cnf or wherever you keep your MySQL configuration. Be sure to add the
system variable to [mysqld] section of the configuration file.



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...