CDash:CodingRules: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
(→‎Date/Time: correct formatting)
 
Line 15: Line 15:
In order to support MySQL and PostGreSQL the date and time should use the following defined variables:
In order to support MySQL and PostGreSQL the date and time should use the following defined variables:


define("FMT_TIME", "H:i:s");  // time
  define("FMT_TIME", "H:i:s");  // time
define("FMT_DATE", "Y-m-d");  // date
  define("FMT_DATE", "Y-m-d");  // date
define("FMT_DATETIME", "Y-m-d\TH:i:s");  // date and time
  define("FMT_DATETIME", "Y-m-d\TH:i:s");  // date and time
define("FMT_DATETIMETZ", "Y-m-d\TH:i:s T");  // date and time with time zone
  define("FMT_DATETIMETZ", "Y-m-d\TH:i:s T");  // date and time with time zone
define("FMT_DATETIMEMS", "Y-m-d\TH:i:s.u");  // date and time with milliseconds
  define("FMT_DATETIMEMS", "Y-m-d\TH:i:s.u");  // date and time with milliseconds


== Count(*) queries ==
== Count(*) queries ==

Latest revision as of 14:29, 6 July 2012

This page describes the coding style and rules to adopt when developing CDash.

Coding Style

Indentation

  • Tabs are not allowed. Tabs should be replaced by two spaces
  • Indentation of curly braces should be as follow:
 if($test == $test2)
   {
   }

Date/Time

In order to support MySQL and PostGreSQL the date and time should use the following defined variables:

 define("FMT_TIME", "H:i:s");  // time
 define("FMT_DATE", "Y-m-d");  // date
 define("FMT_DATETIME", "Y-m-d\TH:i:s");  // date and time
 define("FMT_DATETIMETZ", "Y-m-d\TH:i:s T");  // date and time with time zone
 define("FMT_DATETIMEMS", "Y-m-d\TH:i:s.u");  // date and time with milliseconds

Count(*) queries

 SELECT count(*) FROM ...

is used, then a column named "count(*)" is expected to contain the result. This is not portable and the following query should be used instead:

 SELECT count(*) AS num FROM ...