Useful query – shows how many users registered on a Drupal site each month: select count(uid), month(from_unixtime(created)) as bmonth, year(from_unixtime(created)) as byear from users group by bmonth, byear order by byear, bmonth; SELECT count(uid), MONTH(FROM_UNIXTIME(created)) as bmonth, YEAR(FROM_UNIXTIME(created)) as byear FROM users GROUP BY bmonth, byear ORDER BY byear, bmonth;
Posts Categorized: mySQL
Dumping databases for keeping in version control
Whenever you make a database change, dump it with a script and commit it. This could be a schema change, data change or a settings change you make in the interface of your app (like you do in Drupal). It can be quite hard to get into the habit but it becomes natural after a… Read more »
Convert All Tables in a MySQL Database to InnoDB using PHP
$tables = $db->getAll(“SHOW TABLE STATUS”); foreach($tables as $table){ if($table["Engine"] != “InnoDB”){ echo “converting {$table['Name']} <br>”; $db->query(“ALTER TABLE {$table['Name']} type = innodb”); } }