Category Archives: Code
Drop all tables from a Drupal MySQL database
Handy command to mass-drop all tables: $ drush sql-dump | grep DROP | drush sql-cli
How to retrieve last MySQL INSERT ID from Drupal 7 db_merge()
Drupal 7′s DBTNG database abstraction layer introduces the db_merge() command which replaces the if($id) { db_update() } else { db_insert() } construct. Very useful. One issue I ran into is retrieving the last MySQL insert ID. db_insert() returns the ID … Continue reading
Filed under Code
Easiest way to fix MySQL UTF8 to Latin1 character set encoding issues.
MySQL originally used the latin1 character set by default which stored characters in a 2-byte sequence. In recent versions it defaults to UTF-8 to be friendlier to international users. When migrating MySQL databases, occasionally you’ll see odd characters appear on … Continue reading
Filed under Code