Wednesday, March 28, 2012

Writing drupal module - block with database connection

this is a continuation of my codes done previously to create a block region on right hand side of drupal framesite where it shall display list of contents. This videolog in particular shows the code for database connection via command db_select()->...


In summary, what i've learnt from this exercise are:

  1. writing custom function for buat_sendiri module; this has nothing to do with hook() functions.
  2. Using php time functions; such as getDate(), mktime(hr, min, sec, month, day, year), time()
  3. *** most important command - Using db_select() class. the usage is => db_select('table_name','alias')->fields('alias',array('table_field')->condition('table_field',value)->orderBy('table_field','ASC/DESC')->execute(). an array variable should be assigned to db_select()


Below is the doc on getdate() that i extracted from php.net. The values return are used in mktime().




.

No comments:

Post a Comment