generate($tables, $columns);
}
/**
* Master method to produce workable VO's to work with DAO's.
*
* @param Array $tables array of the tables in the db.
* @param Array $columns recursive array containing all column information.
*/
private function generate($tables, $columns)
{
for ($i = 0; $i < sizeOf($tables); $i++)
{
$this -> output .= '============ ' . ucfirst($tables[$i]) . '.VO.php ============
';
$this -> output .= 'class ' . $tables[$i] . 'VO
{
';
$this -> generateVariables($i, $columns);
$this -> generateSetters($i, $columns);
$this -> generateGetters($i, $columns);
$this -> output .= '}
';
$this -> output .= '============ ' . ucfirst($tables[$i]) . '.VO.php ============
';
}
}
/**
* A method to generate code for the needed variables.
*
* @param Integer $i keeps track of which table for which we are constructing a VO.
* @param Array $columns recursive array containing all column information.
*/
private function generateVariables($i, $columns)
{
for ($j = 0; $j < sizeOf($columns[$i]); $j++)
{
$this -> output .= '/**
';
$this -> output .= ' * Enter description here...
';
$this -> output .= ' *
';
$this -> output .= ' * @var ' .$columns[$i][$j]['Type'] . '
';
$this -> output .= ' */
';
$this -> output .= 'private $' .$columns[$i][$j]['Field'] .';
';
}
$this -> output .= '
';
}
/**
* Method to generate the 'setter' methods.
*
* @param Integer $i keeps track of which table for which we are constructing a VO.
* @param Array $columns recursive array containing all column information.
*/
private function generateSetters($i, $columns)
{
for ($j = 0; $j < sizeOf($columns[$i]); $j++)
{
$this -> output .= '/**
';
$this -> output .= ' * Enter description here...
';
$this -> output .= ' *
';
$this -> output .= ' * @param ' .$columns[$i][$j]['Type'] . ' $' .$columns[$i][$j]['Field'] . '
';
$this -> output .= ' */
';
$this -> output .= 'public function set' . ucfirst($columns[$i][$j]['Field']) . '($' . $columns[$i][$j]['Field'] . ')
';
$this -> output .= '{
';
$this -> output .= '$this -> ' . $columns[$i][$j]['Field'] . ' = $' . $columns[$i][$j]['Field'] . ';
';
$this -> output .= '}
';
}
}
/**
* Method to generate the 'getter' methods.
*
* @param Integer $i keeps track of which table for which we are constructing a VO.
* @param Array $columns recursive array containing all column information.
*/
private function generateGetters($i, $columns)
{
for ($j = 0; $j < sizeOf($columns[$i]); $j++)
{
$this -> output .= '/**
';
$this -> output .= '* Enter description here...
';
$this -> output .= ' *
';
$this -> output .= ' * @return ' .$columns[$i][$j]['Type'] . '
';
$this -> output .= ' */
';
$this -> output .= 'public function get' . ucfirst($columns[$i][$j]['Field']) . '()
';
$this -> output .= '{
';
$this -> output .= 'return $this -> ' . $columns[$i][$j]['Field'] . ';
';
$this -> output .= '}
';
}
}
/**
* Method to get the generated code.
*
* @return String the generated VO(s).
*/
public function getOutput()
{
return $this -> output;
}
}
?>