ok
Direktori : /proc/thread-self/root/proc/self/root/home2/selectio/www/y1jobportal.in/admin/apis/ |
Current File : //proc/thread-self/root/proc/self/root/home2/selectio/www/y1jobportal.in/admin/apis/district.php |
<?php include "../api/config/config.php"; if(isset($_POST['type']) && $_POST['type']=='add_district'){ try{ $pdo->beginTransaction(); $date = date('Y-m-d', time()); $name = $_POST['name']; $state_id = $_POST['state_id']; $statement = $pdo->prepare("INSERT INTO `district`(`district_name`,`state_id`,`status`) VALUES (?,?,?)"); $result = $statement->execute(array($name,$state_id,1)); if($result){ $last_inserted_id = $pdo->lastInsertId(); $pdo->commit(); $return_arr['message']='Dustrict Details Addded Successfully...'; $return_arr['status']=200; } else{ $return_arr['message']='Something Went Wrong..'; $return_arr['status']=400; } }catch(PDOException $e){ $return_arr['message']="$e"; error_log("Query Error: ".$e); $return_arr['status']=500; $pdo->rollBack(); } echo json_encode($return_arr); } if(isset($_POST['type']) && $_POST['type']=='update_district'){ try{ $pdo->beginTransaction(); $date = date('Y-m-d', time()); $ids = $_POST['ids']; $name = $_POST['name']; $state_id = $_POST['state_id']; $status = $_POST['status']; $statement = $pdo->prepare("UPDATE `district` SET `district_name`=?, `state_id`=?, `status`=? WHERE id=?"); $result = $statement->execute(array($name,$state_id,$status, $ids)); if($result){ $last_inserted_id = $pdo->lastInsertId(); $pdo->commit(); $return_arr['message']='District Details Updated Successfully...'; $return_arr['status']=200; } else{ $return_arr['message']='Something Went Wrong..'; $return_arr['status']=400; } }catch(PDOException $e){ $return_arr['message']="$e"; error_log("Query Error: ".$e); $return_arr['status']=500; $pdo->rollBack(); } echo json_encode($return_arr); } ?>