<?php
class DAOFactory {
private static $_instance = null;
private static $_dbhost;
private static $_user;
private static $_password;
private static $_dbname;
private function __construct ( $host, $user, $pwd, $dbname ) {
self::$_dbhaost = $host;
self::$_user = $user;
self::$_password = $pwd;
self::$_dbname = $dbname;
}
public function clear() {
self::$_instance = null;
}
public static function getInstance() {
if ( is_null ( self::$_instance ) && func_num_args() == 4 ) {
$host = func_get_arg ( 0 );
$user = func_get_arg ( 1 );
$pwd = func_get_arg ( 2 );
$dbname = func_get_arg ( 3 );
self::$_instance = new self ( $host, $user, $pwd, $dbname );
}
return self::$_instance;
}
public function createDAO ( $classname ) {
switch ( strtoupper ( $classname ) ) {
case 'SURVEY':
include ( 'com/adcom/creativesurvey/surveydao.php' );
return new surveyDAO ( self::$_dbhost, self::$_user, self::$_password, self::$_dbname );
break;
case 'CREATIVE':
include ( 'com/adcom/creativesurvey/creativedao.php' );
return new creativeDAO ( self::$_dbhost, self::$_user, self::$_password, self::$_dbname );
break;
}
}
}
?>