Community Developer Information
From OpenWiki
Contents |
[edit] PHP Standards
- Use only tabs for indentation, you may need to adjust the settings for your IDE or editor to ensure tabs are not replaced by spaces in your editor.
- Use single quotes instead of double quotes when variable interpolation is not needed.
- Brackets should begin on the same line as the control structure... if($booleanValue) {
- Method names and variables use studlyCaps
- Class names must begin with an UpperCase and the first letter of each word is capitalized
To sum up
if ($booleanValue) {
$someVariableName = true;
$someOtherVariableName = true;
} else {
$differentVariableName = true;
$someObject = new MyClass();
$someObject->name = 'My var value';
}
[edit] SQL Standards
- Use uppercase wording for all SQL reserved words
- Use 'AS' operator when creating an alias for a table or column
- Use parenthesis for all JOIN conditions
- Use INNER JOIN instead of JOIN
- Parenthesis should have no whitespace between to their left
- Use one line for the query if the query and indenting are no longer than 110 characters, otherwise
- Use multi-line queries for queries longer than 110 characters
[edit] Example queries
SELECT t1.* FROM table AS t1 INNER JOIN table AS t2
Or:
SELECT
t1.*,
t2.*
FROM
table AS t1
INNER JOIN table AS t2 ON (t1.id = t2.parent_id)
WHERE
t2.column = "value"
[edit] Database Schema Naming Convention
- All table names should be the singular form of the word, e.g. patient for the patients table
- In the case of multi word table or field names then words should be separated by an underscore, e.g. patient_address for the patient address table and home_address for the home address field
- The primary key field on a table should be named for the table and end in _id, e.g. patient_id for the id field in the patient table
