Hi guys! Since I'm not a member of any PHP forum and I'm just trying to play with PHP OOP (for some extra cash and some fun hehehe)
I have a class which implements an interface...
<?php
//require_once("dao_includes.php");
class MySQLDAO implements DAO
{
private $username;
private $password;
private $host;
private $port;
private $dsn;
private static $instance;
private function __construct($_username, $_password, $_host, $_port)
{
$username = $_username;
$password = $_password;
$host = $_host;
$port = $_port;
$dsn = $host . ":" . $port;
//echo "Constructing MySQLDAO...<br/>";
}
/**
*
* @override
*/
public function initializeConnection()
{
echo "username: " . $username . "<br/>";
echo "dsn: " . $dsn;
mysql_connect($dsn, $username, $password) or die("Cannot connect to MySQL Database");
}
/**
*
* Returns only a single instance
*/
public static function getInstance()
{
if ( !isset($instance) )
{
//require_once("mysql_connection_properties.php");
//$instance = new MySQLDAO($MYSQL_USERNAME, $MYSQL_PASSWORD, $MYSQL_HOST,
$MYSQL_PORT);
$instance = new MySQLDAO("root", "admin456", localhost, "3306");
//return self::$instance;
return $instance;
}
}
}
?>
Now, this is instantiated from a factory class...
<?php
require_once("dao_essentials.php");
class DAOFactory
{
public static $MYSQL_DAO = 1;
public static function getDAO($db)
{
return MySQLDAO::getInstance();
}
}
?>
and eventually, I make an instance of MySQLDAO like this...
<?php require_once("db/dao_essentials.php"); ?>
<?php
//phpinfo();
$dao = DAOFactory::getDAO( DAOFactory::$MYSQL_DAO );
$dao->initializeConnection();
?>
Although the call to initializeConnection() succeeds(I can get the MySQLDAO object), my member variables $username, $password, etc. are all empty when I try to print it! Why is that?
Thanks!

Convert limitations to great expectations... You are the creative force of your life...