<?php $modx->addPackage('profut', $modx->getOption('core_path').'components/profut/model/'); $user = $modx->getUser(); $pfUser = $modx->getObject('ProfutUsers', array('uid' => $user->get('id'))); $pfUserArray = array(); if ($pfUser) { // true echo "update "; $pfUserArray = $pfUser->toArray(); } else { echo "create "; $pfUser = $modx->newObject('ProfutUsers'); $pfUserArray['uid'] = $user->get('id'); $pfUserArray['team_id'] = 0; $pfUserArray['role'] = 0; } echo $pfUser->get('way_id') . ' '; // 1 // ((int) $hook->getValue('casetype')) == 2 $pfUserArray['way_id'] = ((int) $hook->getValue('casetype')); $pfUser->fromArray($pfUserArray); echo $pfUser->get('way_id') . ' '; // 2 $pfUser->save(); echo $pfUser->get('way_id') . ' '; // 2 $pfUser = $modx->getObject('ProfutUsers', array('uid' => $user->get('id'))); echo $pfUser->get('way_id') . ' '; // 1 die();
update 1 2 2 1
$pfUserArray['edu_inst'] = strip_tags(htmlspecialchars(mysql_escape_string($hook->getValue('eduinst'))));
<?php $modx->addPackage('profut', $modx->getOption('core_path').'components/profut/model/'); $user = $modx->getUser(); $pfUser = $modx->getObject('ProfutUsers', array('uid' => $user->get('id'))); $pfUserArray = array(); if ($pfUser) { // true echo "update "; $pfUserArray = $pfUser->toArray(); } else { echo "create "; $pfUser = $modx->newObject('ProfutUsers'); $pfUserArray['uid'] = $user->get('id'); $pfUserArray['team_id'] = 0; $pfUserArray['role'] = 0; } echo $pfUser->get('way_id') . ' '; // 1 // ((int) $hook->getValue('casetype')) == 2 $pfUserArray['way_id'] = ((int) $hook->getValue('casetype')); $pfUser->fromArray($pfUserArray); echo $pfUser->get('way_id') . ' '; // 2 // $pfUser->set('way_id',((int) $hook->getValue('casetype'))); // $pfUser->save(); echo $pfUser->get('way_id') . ' '; // 2 $pfUser = $modx->getObject('ProfutUsers', array('uid' => $user->get('id'))); echo $pfUser->get('way_id') . ' '; // 1 die();
CREATE TABLE IF NOT EXISTS `modx_profut_users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uid` int(11) DEFAULT NULL, `role` int(11) DEFAULT '0', `edu` text, `edu_inst` text, `edu_class` text, `edu_spec` text, `case_type` text, `work_exp` text, `work_exp_desc` text, `team_id` int(11) DEFAULT '0', `rank1` int(11) DEFAULT '0', `rank2` int(11) DEFAULT '0', `rank3` int(11) DEFAULT '0', `test_data1` text, `test_data2` text, `test_data3` text, `league_id` int(11) DEFAULT '0', `way_id` int(11) DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `uid` (`uid`) ) ENGINE=MyISAM AUTO_INCREMENT=159 DEFAULT CHARSET=utf8;