} if ($varverb == true) { return "SUCCESS: DELETED " . $rows . " RECORDS."; } else { return "SUCCESS: " . $rows; } } ###################################################################### # ACTIONS # # This section parses the "action" parameter and decides what to do. ###################################################################### switch ($action) { case 'put': echo update_data($dbtable, $key, combine_arrays($fields, $values), $verbose); break; case 'get': if ($reverse == true) { echo retrieve_fields($dbtable, $key, $values, $verbose, $separator); } else { echo retrieve_values($dbtable, $key, $fields, $verbose, $separator); } break; case 'del': if ($reverse == true) { echo delete_fields($dbtable, $key, $values, $verbose); } else { echo delete_values($dbtable, $key, $fields, $verbose); } break; }
foreach ($func_params as $key) { $key_value = $key; $insert_handle->execute(); } } $json_verified[$cur_index]["Results"] = pull_values($userid, $table_name); $cur_index = $cur_index + 1; $delete_handle = $db_connection->Prepare("drop table #TempID"); $delete_handle->execute(); } else { foreach ($op_index as &$func_params) { $json_verified[$cur_index] = array(); $json_verified[$cur_index]["Table"] = $table_name; $json_verified[$cur_index]["Operation"] = $op_name; if ($op_name == 'Delete') { $json_verified[$cur_index]["Results"] = delete_values($userid, $func_params, $table_name); } else { if ($op_name == 'Insert' || $op_name == 'Update') { $json_verified[$cur_index]["Results"] = insert_or_update($userid, $op_name, $func_params, $table_name); } } $cur_index = $cur_index + 1; } } } } $json_verified['NumElements'] = $cur_index; $db_connection = null; //Auto sets to true, each operation can fail or succeed on //its own. $json_verified['Verified'] = true;
$return_json = insert_or_update($userid, $operation, $params, $table); $return_json["Operation"] = $operation; echo json_encode($return_json); } catch (Exception $except) { echo "Invalid Token. Try logging out and in again."; } break; case "Delete": $userid = 0; require '/var/www/dbconnection/Sign_jwt.php'; try { $userid = JWTSign::decode_token($http_post["Token"]); $params = json_decode($http_post["Params"], true); $table = $http_post["Table"]; require '/var/www/dboperations/delete_values.php'; $return_json = delete_values($userid, $params, $table); $return_json["Operation"] = $operation; echo json_encode($return_json); } catch (Exception $except) { echo "Invalid Token. Try logging out and in again."; } break; case "Sync": $userid = 0; require '/var/www/dbconnection/Sign_jwt.php'; try { $userid = JWTSign::decode_token($http_post["Token"]); $params = json_decode($http_post["Params"], true); $table = $http_post["Table"]; require '/var/www/dboperations/sync.php'; } catch (Exception $except) {