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();

Curl on Localhost and WAMP on x64

I was going nuts over how to install CURL on 64 bit windows. I need it for some module and just enabling it from Wamp panel didn't work. So I searched for solutions and there are quite a few combos and solutions offered online but the only thing that worked for me and what was needed is

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 Drush Command Cheat Sheet Copy

Everbody likes Drush, why wouldn't you. Anyway I copied cheat sheet from some PDF as this is a drupal dump site and this way I can find it quicker and make also some additions to it.

When available, there is a shorter version of the same command in parentheses.

cache clear (cc) Clear all caches.

cron Run all cron hooks.