<?php include '../classes/Database.php'; $db = new Database(); $action = $_GET['action']; if ($action == 'delete') { $id = $_GET['id']; if ($db->Delete('payments', ['idpay' => $id])) { echo 'OK'; } else { echo 'ERROR'; } } if ($action == 'add') { $inserts = "INSERT INTO `payments` (`amount`,`payment_for`,`payer`,`payment_date`,`additional`) VALUES "; $tmp = ''; $rows = count($_POST) - 1; $cnt = 0; foreach ($_POST as $index => $array) { $tmp .= '('; $cntr = 0; $all = count($array) - 1; foreach ($array as $k => $v) { if ($cntr !== $all) { $tmp .= '"' . $v . '",'; } else { $tmp .= '"' . $v . '"'; } $cntr++; } if ($cnt !== $rows) {
<?php require_once "../Engine/DatabaseClass.php"; echo "Testes usuarios<br><br>"; $data = new Database("localhost", "root", "root", ""); echo "Teste INSERT:<br>"; $params = array("Parametro1" => "1", "Parametro2" => "2"); $data->Insert("teste", $params); echo "<br><br>"; echo "Teste DELETE<br>"; $where_clauses = array("Parametro1" => "1", "Parametro2" => "2"); $union_clauses = array("AND"); $data->Delete("teste", $where_clauses, $union_clauses); echo "<br><br>"; echo "Teste UPDATE<br>"; $values = array("Nome" => "Jose", "Idade" => "20"); $where_clauses = array("Parametro1" => "1", "Parametro2" => "2"); $union_clauses = array("AND"); $data->Update("teste", $values, $where_clauses, $union_clauses); echo "<br><br>"; echo "Teste SELECT<br>"; $where_clauses = array("Parametro1" => "1", "Parametro2" => "2"); $union_clauses = array("AND"); $data->Select("teste", null, $where_clauses, $union_clauses); echo "<br><br>"; echo "Teste SELECT 2<br>"; $cols = array("nome", "idade"); $where_clauses = array("Parametro1" => "1", "Parametro2" => "2"); $union_clauses = array("AND"); $data->Select("teste", $cols, $where_clauses, $union_clauses);
Database::UpdateGeneric('mission', $mission, "WHERE id_mission = {$id_mission}"); if ($mission['STATUS'] == 'Concluida' || $mission['STATUS'] == 'Cancelada') { Database::Update('team', 'STATUS = "Disponível"', "WHERE id_team = " . $mission['ID_TEAM']); } else { Database::Update('team', 'STATUS = "Ocupada"', "WHERE id_team = " . $mission['ID_TEAM']); } echo 'success'; break; case 'alterEquipe': $id_team = $_POST['ID_TEAM']; $team['NAME_TEAM'] = $_POST['NAME_TEAM']; $team['ID_LEADER'] = $_POST['ID_LEADER']; $team['STATUS'] = $_POST['STATUS']; $integrantes = $_POST['CALEBES_MISSAO']; Database::UpdateGeneric('team', $team, "WHERE id_team = {$id_team}"); Database::Delete('team_calebe', "WHERE id_team = {$id_team}"); Database::Insert('team_calebe', 'ID_TEAM, ID_CALEBE', "{$id_team}, " . $team['ID_LEADER']); foreach ($integrantes as $id_integrante) { Database::Insert('team_calebe', 'ID_TEAM, ID_CALEBE', "{$id_team}, {$id_integrante}"); } echo 'success'; break; case 'alterIgreja1': $_SESSION['in'] = $_POST; break; case 'alterIgreja2': $id_church = $_SESSION['in']['ID_CHURCH']; $church['NAME_CHURCH'] = $_SESSION['in']['NAME_CHURCH']; $church['NAME_PASTOR'] = $_SESSION['in']['NAME_PASTOR']; $church['STATUS'] = $_SESSION['in']['STATUS']; $id_address = $_POST['ID_ADDRESS'];
<?php include '../classes/Database.php'; $db = new Database(); $action = $_GET['action']; if ($action == 'delete') { $id = $_GET['id']; if ($db->Delete('groups', ['idg' => $id])) { echo 'OK'; } else { echo 'ERROR'; } } if ($action == 'deletestudentfromgroup') { $idg = $_GET['groupid']; $ids = $_GET['studentid']; $module = $_GET['module']; if ($db->Update('students', [$module . '_group' => 'NULL'], [$module . '_group' => $idg, 'ids' => $ids])) { echo 'OK'; } else { echo 'ERROR'; } }
<?php session_start(); include_once '../class/Functions.php'; include_once '../class/Address.php'; $acao = $_POST['acao']; switch ($acao) { case 'Delete': $id = $_POST['id']; $table = $_POST['table']; Database::Delete($table, "WHERE id_{$table} = {$id}"); echo 'success'; break; case 'saveReligion': $religion = $_POST['NAME_RELIGION']; if (Database::ReadOne('religion', '*', "WHERE name_religion = '{$religion}'")) { echo 'exist'; } else { Database::Insert('religion', 'NAME_RELIGION', "'{$religion}'"); echo 'success'; } break; case 'saveAdmin1': $email = $_POST['EMAIL']; $phone = $_POST['PHONE']; $name = $_POST['NAME_PERSON']; if (!Functions::validEmail($email)) { echo 'email'; } else { if (Database::ReadOne('person', '*', "WHERE name_person = '{$name}'")) { echo 'exist';