本文整理汇总了PHP中UserData::setUserDataId方法的典型用法代码示例。如果您正苦于以下问题:PHP UserData::setUserDataId方法的具体用法?PHP UserData::setUserDataId怎么用?PHP UserData::setUserDataId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserData
的用法示例。
在下文中一共展示了UserData::setUserDataId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateUserData
public static function updateUserData()
{
$userDataArray = UserDataDB::getUserDataBy('userDataId', $_SESSION['arguments']);
if (empty($userDataArray)) {
HomeView::show();
header('Location: /' . $_SESSION['base']);
} elseif ($_SERVER["REQUEST_METHOD"] == "GET") {
$_SESSION['userData'] = $userDataArray[0];
UserDataView::showUpdate();
} else {
$userData = $userDataArray[0];
$parms = $userData->getParameters();
$parms['userId'] = array_key_exists('userId', $_POST) ? $_POST['userId'] : $userData->getUserId();
$parms['user_name'] = array_key_exists('user_name', $_POST) ? $_POST['user_name'] : "";
$parms['skill_level'] = array_key_exists('skill_level', $_POST) ? $_POST['skill_level'] : "";
$parms['skill_areas'] = array_key_exists('skill_areas', $_POST) ? $_POST['skill_areas'] : array();
$parms['profile_pic'] = array_key_exists('profile_pic', $_POST) ? $_POST['profile_pic'] : "";
$parms['started_hobby'] = array_key_exists('started_hobby', $_POST) ? $_POST['started_hobby'] : "";
$parms['fav_color'] = array_key_exists('fav_color', $_POST) ? $_POST['fav_color'] : "";
$parms['url'] = array_key_exists('url', $_POST) ? $_POST['url'] : "";
$parms['phone'] = array_key_exists('phone', $_POST) ? $_POST['phone'] : "";
$newUserData = new UserData($parms);
$newUserData->setUserDataId($userData->getUserDataId());
$userDataEntry = UserDataDB::updateUserData($newUserData);
if ($userDataEntry->getErrorCount() != 0) {
$_SESSION['userData'] = array($newUserData);
//return;
UserDataView::showUpdate();
} else {
HomeView::show();
header('Location: /' . $_SESSION['base']);
}
}
}
示例2: getUserDataArray
public static function getUserDataArray($rowSets)
{
$usersData = array();
if (!empty($rowSets)) {
foreach ($rowSets as $userDataRow) {
$userData = new UserData($userDataRow);
$userDataId = $userDataRow['userDataId'];
// The UserData constructor does not set the userDataId for
// a new UserData object; the UserData table takes care of that
// during insertion. Here we manually set the userDataId to
// complete the UserData object.
$userData->setUserDataId($userDataId);
// We should also get the user's associated skills
$skillAssocs = SkillAssocsDB::getSkillAssocsBy('userDataId', $userDataId);
$skill_areas = array();
foreach ($skillAssocs as $skillAssoc) {
$skillId = $skillAssoc->getSkillId();
// skillIds start from 1, however array-indexing
// starts at 0; so we use an offset of -1 when retrieving
// values from $SKILL_AREAS
$skill_name = Skill::$SKILL_AREAS[$skillId - 1];
array_push($skill_areas, $skill_name);
}
$userData->setSkillAreas($skill_areas);
array_push($usersData, $userData);
}
}
return $usersData;
}
示例3: testUpdateUserData
public function testUpdateUserData()
{
$myDB = DBMaker::create('botspacetest');
Database::clearDB();
$db = Database::getDB('botspacetest', 'C:\\xampp\\myConfig.ini');
$testUserDataId = 1;
$userDataArray = UserDataDB::getUserDataBy('userDataId', $testUserDataId);
$userData = $userDataArray[0];
$params = $userData->getParameters();
$this->assertEquals($userData->getUserName(), 'jabituya', 'Before the update it should have username jabituya');
$testUserDataRowsArray = UserDataDB::getUserDataRowSetsBy('userDataId', $testUserDataId);
$testUserDataRow = $testUserDataRowsArray[0];
$params['user_name'] = 'jabituya2000';
$newUserData = new UserData($params);
$newUserData->setUserDataId($testUserDataId);
$userData = UserDataDB::updateUserData($newUserData);
$this->assertEquals($userData->getUserName(), 'jabituya2000', 'After the update it should have username jabituya2000');
$this->assertTrue(empty($userData->getErrors()), 'The updated user data should have no errors');
}