XAMPP DB Import for Mac using Terminal

/Applications/XAMPP/xamppfiles/bin/mysql -u {username} -p {password} {db name} < {target .sql file}

So mysql on XAMPP has a file size limit on how large the imported .sql file can be. To get around this, there’s 2 solution:

  1. Increase the limit (though this wasn’t working for me).
  2. Import the db through terminal which bypass this limit.

The above command can be used by Mac users to import sql to their desired db on XAMPP. Note that you want to be where the target .sql file location is.



 * Implements hook_entity_presave().
 * @param $entity
function hook_entity_presave($entity) {
  if (isset($entity->type) && $entity->type == 'estimate') {

hook_entity_presave() is run before the entity is saved. This applies for both the initial creation of an entity, and saving a edited entity.

In the example provided, I check the type of entity, before parsing $entity to another function.


 * Implements hook_form_views_exposed_form_alter().
 * Set the default exposed filter value.
 * @param $form
 * @param $form_state
function hook_form_views_exposed_form_alter(&$form, &$form_state) {
  if (!isset($form_state['input']['field_date_value_1']['value']['date'])) {
    $form_state['input']['field_date_value_1']['value']['date'] = date("Y-m", strtotime("+1 month"));

hook_form_views_exposed_form_alter() is run before the form is rendered. It’s hook_form_alter(), but with the form_id of view_exposed_form.

In the example I provided, I have a date filter with the name of: field_date_value_1.

By default, the value of the filter is empty. I want to change that. The code checks whether the filter value is set. If not, it sets the filter date value to that of next month.

Drupal Development

I’m a Junior Software Engineer, currently situated in Shanghai. As of the moment, my work heavily involves the use of Drupal.

What is Drupal?

Drupal, known as Drupal core, contains basic features common to content-management systems. These include user account registration and maintenance, menu management, RSS feeds, taxonomy, page layout customization, and system administration.

Extract from Wikipedia.

That’s the basics.

As a Drupal developer, I develop custom modules that is capable of unique functions that Drupal cannot achieve by default.

This blog is not a guide on how to use Drupal, but for me to write down example of codes that I find will be useful for future references, and/or may be useful for other new Drupal developers.

For more information of Drupal, please check out their official website.