function updateimage($StoreItem) { $Model = new mStoreItemImage($StoreItem); if ($_POST['field'] == 'order') { $Other = new mStoreItemImage(); $Other->order = $_POST['value']; $Other->load(); $Other->order = $Model->order; } $Model->{$_POST['field']} = $_POST['value']; $Result['result'] = $Model->save(); $this->output->delete_cache('/'); if ($Result['result'] === true && isset($Other) && $Other->is_loaded()) { $Other->save(); } echo json_encode($Result); }