CakePHP - Execution order of multiple validation rules

Below is a typical validations rules for User Model. The validations rules of a field are ran from bottom up. In this case, for the email field, it will run stringLength, email and then isUnique rules.

class User extends AppModel
  var $name = "User";
  // Validation rules.
  var $validate = array(
            'message'=>'This username has already been taken.',

Ant - Using timestamp

Example of using timestamp

Ant - Ant with JUnit4

Sample Ant build file to run JUnit

<?xml version="1.0" encoding="UTF-8"?>
  Filename: build.xml
  Note: You have to change the followings according to your environment:
          -<pathelement location="bin"/>
          -<pathelement location="lib/junit/junit-4.8.2.jar"/>
          -<test name="x.x.x.x.x.x" todir="${junit.output.dir}"/>
<project basedir="." default="junit" name="Sample of Ant file for JUnit">
  <property name="junit.output.dir" value="junit"/>
  <path id="junit.classpath">

SQL - MS Access

Useful Functions

Nz( variant, [ value_if_null ] )
Return defined value if variant is null. value_if_null is optional. If value_if_null is not defined, then it will return zero-length string. Example of usage in MS Access Query Design View: Field: Expr1: Nz(AnyColumValue, "Value is null")
Ask for user input in query
You can use square bracket to ask for user input each time that the query is ran.
SELECT TableA.col
WHERE TableA.col=[Enter a VALUE];

SQL - Oracle


Check Oracle version
  1. Login to SQL *Plus.
  2. Get the version by running query:
    SELECT * FROM v$version;


Escape underscore(_) in LIKE statement
To escape underscore(_) in LIKE statement, you have to enclose the underscore(_) inside square brackets.
-- Select all values that end with _B.
WHERE TableA.col LIKE '%[_]B';
Check SQL Server version and edition
SELECT  SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition');
Copy all data of a table to another 1

SQL - Comparing tables using LEFT and RIGHT JOINS

Comparing tables using LEFT and RIGHT joins is easy. We will exploit the definitions of the LEFT and RIGHT joins to compare every records in every columns of each table. By definition, the LEFT join will returns all records of the left table even though the ON clause doesn't find any matching records on the right table. The non-matching records in the right table is still returned with the record of the left table but its value is NULLed. The RIGHT join is exactly the same as the LEFT join, except that it returns all records of the right table instead of the left table.

DOS - Variable

Set variable To declare a variable, use the following syntax:

SET variablename="value"

Call variable To call the variable, use the following syntax:


Subscribe to RSS