Mostly I make use of the MVC principle with static Mappers to connect the database rows to te models. By example:
/**
* Find the requested user by its username
*
* @todo handle no results
*
* @param mixed $sUserName
* @return Employees_Model
*/
public static function findByUserName( $sUserName ) {
if( isset( $sUserName ) ) {
$oDBH = new DataController();
$stmt = $oDBH->prepare('SELECT * FROM Employees WHERE sUserName = :username');
$stmt->bindParam('username', $sUserName, PDO::PARAM_STR);
$stmt->execute();
$aData = $stmt->fetch();
$oModel = new Employees_Model();
$oModel->setModel($aData);
return $oModel;
} else {
throw new InvalidArgumentException('Given parameter is empty');
}
}
|
When I call this function like this:
$oUser = Employees_Mapper::findByUserName(Request::sessionParam('userName'));
and try to auto complete $oUser-> only an error pops up saying:
'failed to identify the type of $oUser'
What is the problem? The phpdoc generator does work perfect and can figure out what the return statement holds.[/code]