本文整理汇总了PHP中sfGuardUser::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP sfGuardUser::getTable方法的具体用法?PHP sfGuardUser::getTable怎么用?PHP sfGuardUser::getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfGuardUser
的用法示例。
在下文中一共展示了sfGuardUser::getTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doSave
public function doSave($con = null)
{
// autogenerage a suitable username
if (!isset($values['username'])) {
srand(time());
$username = $this->getValue('firstname').'_'.substr($this->getValue('lastname'), 0, 1).'_'.rand(1, 1000);
$usr = new sfGuardUser();
while ($usr->getTable()->retrieveByUsername($username))
{
$username = $this->getValue('firstname').'_'.substr($this->getValue('lastname'), 0, 1).'_'.rand(1, 1000);
}
$this->values['username'] = $username;
}
// do all the saving magic
return parent::doSave($con);
}
示例2: dirname
include dirname(__FILE__) . '/../../bootstrap/functional.php';
/**
* This is an example class of sfTestFunctional
* It may require some attention to work with the default values (line 40).
*/
$browser = new sfBrowser();
$test_browser = new sfTestFunctional($browser);
$test_browser->setTester('json.response', 'sfTesterJsonResponse');
$test_browser->get('/user')->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->end()->with('json.response')->begin()->isJson()->end();
/**
* Test the creation
*/
$entity = new sfGuardUser();
$entity_array = $entity->exportTo('array');
$identifier = $entity->getTable()->getIdentifier();
/**
* Please build a valid $entity_array here
*/
unset($entity_array[$identifier]);
//$entity_array['name'] = "pony";
//$entity_array['created_at'] = date('Y-m-d H:i:s');
//$entity_array['updated_at'] = date('Y-m-d H:i:s');
$test_browser->call('/user', 'post', array('content' => json_encode($entity_array)))->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'create')->end()->with('response')->begin()->isStatusCode(200)->end();
/**
* If the new entity has been created
*/
$location = $browser->getResponse()->getHttpHeader('Location');
if ($location) {
// Get ?
$test_browser->get($location)->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'show')->end()->with('response')->begin()->isStatusCode(200)->end()->with('json.response')->begin()->isJson()->end();