Custom Functions in yii

As par normal site (without framework )generally programmer will get repeated data using Functions

like :- get logged Customer name

function getLoggedCustomerName($cId){

$conn = $this->getDbConnection();

$query = 'SELECT Name from tab_name WHERE id ’ $cId;

$rows = $conn->createCommand($query)->queryRow();

return $rows[‘Name’];

}