Hey Guys,
I am trying to update a 3rd party table here is the code I am using
<?php
if(isset($_POST) AND isset($_POST['site_id_val'])){
if(isset($_POST['module_order']) and !empty($_POST['module_order'])){
parse_str($_POST['module_order'], $_POST['module_order']);
$_POST['module_order'] =$_POST['module_order']['modules'];
}
//update the module settings
$base_path = !empty($base_path) ? $base_path : $modx->getOption('core_path').'components/ModuleOptions/';
$modx->addPackage('ModuleOptions',$base_path.'model/');
//foreach($_POST['SiteMods'] As $name =>$s){
$stack = $modx->getCollection('SitesOptions', array(
'sites_id' => $_POST['site_id_val']
));
if(!$stack){
var_dump($stack);
DIE();
return;
}
foreach($stack as $object) {
echo "
Current: Saved ".$object->get('sites_option')." VAL: ".$object->get('sites_value');
if(!isset($_POST['SiteMods'][$object->get('sites_option')]) OR empty($_POST['SiteMods'][$object->get('sites_option')]))
continue;
$object->set('sites_value', $_POST['SiteMods'][$object->get('sites_option')]);
$object->set('sites_option', $object->get('sites_option'));
if($object->save()){
echo "
Success: Saved ".$object->get('sites_option')." TO: ".$_POST['SiteMods'][$object->get('sites_option')];
}
}
}
The output of those echo's is :
Current: Saved country VAL: US||CA||DE
Success: Saved country TO: US||CA||GB
Current: Saved run VAL: no
Success: Saved run TO: no
Current: Saved check VAL: yes
Success: Saved check TO: yes
As far as I can see it is saving it just fine to modx but when I do a select from the table itself its not updated at all. Any thoughts on where I went wrong