Created
September 1, 2012 15:56
-
-
Save petrabarus/3578305 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* In the config | |
*/ | |
return [ | |
'components' => [ | |
'urlManager' => [ | |
'rules' => [ | |
//.... | |
//let's assume 'view' is not eligible for a username :) | |
'member/<username:\w+>' => 'member/view', | |
//.... | |
] | |
] | |
] | |
]; | |
/** | |
* In the controller | |
*/ | |
class MemberController extends \CController { | |
public function actionView($username){ | |
$user = User::model()->find([ | |
'condition' => 'username = :username', | |
'params' => [ | |
':username' => $username | |
] | |
]); | |
if ($user === NULL){ | |
throw new CHttpException(404); | |
} | |
$this->render('view', [ | |
'user' => $user | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment