Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $MyData=$_REQUEST['pass'];
- include('Connectoperations.php');
- function Check_DoIn($table,$ID)
- {
- var_dump($table, $ID);
- $json=singleval($table,'ID','',"Where ID=".$ID,'');
- var_dump($json);
- $myjson = json_decode($json, TRUE);
- if ($myjson["ID"]=="")
- //is not in do an insert
- return 0;
- else
- //is in do an update
- return 1;
- }
- $passingJson=$MyData;
- //echo $passingJson;
- $myjsoncheck = json_decode($passingJson, TRUE);
- // echo $myjsoncheck["Table"];
- if (sizeof( $myjsoncheck['results'])>0){
- $Mytable=$myjsoncheck["Table"];
- $Messagein=$myjsoncheck["message"];
- foreach ($myjsoncheck['results'] as $f)
- { //echo $Mytable;
- if (Check_DoIn($Mytable,$f["ID"])==0)
- {
- //echo "Doinsert";
- $MyAttributes="";
- $MyValues="";
- $MyWhere='Where ID='.$f["ID"];
- //Get the table attributes and values
- foreach($f as $key => $value)
- {
- $MyAttributes=$MyAttributes ."," . $key;
- $MyValues=$MyValues . ',"'.$value.'"';
- }
- $MyAttributes =substr($MyAttributes,1);
- $MyValues =substr($MyValues,1);
- echo insert($Mytable,$MyAttributes,$MyValues,"",$Messagein);
- }else
- {
- //echo ",DoUpdate";
- echo updateJson($f,$Mytable,$Messagein);
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement