WSOD or white screen of death and error reporting

Sometimes you will have a WSOD and nothing to show for. One simple solution to get what is a problem is to insert the following lines into the Drupal's index.php, that should set PHP to report all errors.

Converting Form API date field to timestamp

If you are not using a date module and just want to use date field from form api, you will want to insert it into DB, probably as timestamp. So to convert that value to timestamp you need to use some precoding for that. In this example we also use a simple textfield to enter time value and add it to timestamp. Also take a note we are using timezone value.

Database API, several ways to retrieve data from query



$uid = 1;
$result = db_query('SELECT n.nid, n.title, n.created
FROM {node} n WHERE n.uid = :uid', array(':uid' => $uid));

Fetch next row as a stdClass object.
$record = $result->fetchObject(); 

Fetch next row as an associative array.
$record = $result->fetchAssoc();

Sorting array of objects by value

Drupal uses many multidimensional arrays and usually you won't need to do this, or will do it in some theme layer or with views. But I did have a case where I needed to sort out array of entities by score value so I did it this way.

Getting host node and node id of field collection

I was killing myself to get host node and node.id of field_collection I am using so I can do some preprocessing before this node is saved. I was trying with field_collection_item_get_host_entity but just couldn't make it work. So I asked google and found out I can do it with regular host function like

Getting host node and node id of field collection

I was killing myself to get host node and node.id of field_collection I am using so I can do some preprocessing before this node is saved. I was trying with field_collection_item_get_host_entity but just couldn't make it work. So I asked google and found out I can do it with regular host function like

Module paths in DB

Working with multi sites and modules located in sites/all and sites/some_site your module paths could get in problems. So for a fix check you just need to replace paths in your DB like

Drupal missing modules and white screen of death

WSOD (white screen of death) can happen in drupal for different reasons. One is that you could be missing some files, probably modules. Maybe you moved something wrong when migrating, or you have wrong git branch or just delete module(s).