Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts

May 16, 2010

MySQL strings and upper case

MySQL strings are compared case insensitively. A field with a value of "something" is equal to "SOMETHING", making it difficult to compare upper and lower case strings. A simple workaround is to use a hashing function to compare them. MD5 is overkill for this, but it works :P

Finding all records with an upper cased field:
SELECT IdField, SomeField 
  FROM DatabaseTable 
  WHERE MD5(SomeField)=MD5(UCASE(SomeField)) 

Converting all field values to pseudo-proper case (first character caps, rest lower case):
UPDATE DatabaseTable 
  SET SomeField = CONCAT(UCASE(MID(SomeField,1,1)), LCASE(MID(SomeField,2))) 
  WHERE MD5(SomeField)=MD5(UCASE(SomeField))

May 13, 2010

Disabling the phpMyAdmin timeout after 1440 seconds

The timeout is cookie-based and can be disabled by storing the MySQL authentication information in the config.inc.php file. To do this, just add the following to the file:


$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'your-database-user-name';
$cfg['Servers'][$i]['password'] = 'your-database-password';

Note: doing this will remove the login prompt, so only do this if your phpMyAdmin installation is locked down with a server-based authentication!