public static function updateMessage($message) { $consulta = "UPDATE " . self::NAME_TABLE . " SET " . self::DESCRIPTION . "=?" . " WHERE " . self::ID . "=1"; $sentencia = ConnectionDB::getInstance()->getDB()->prepare($consulta); $sentencia->bindParam(1, $message); $sentencia->execute(); return $sentencia->rowCount(); }
public static function getAppId($appKey) { $command = "SELECT " . self::ID . " FROM " . self::NAME_TABLE . " WHERE " . self::ACCESS_KEY . "=?"; $sentence = ConnectionDB::getInstance()->getDB()->prepare($command); $sentence->bindParam(1, $appKey); if ($sentence->execute()) { $result = $sentence->fetch(); return $result['id']; } else { return null; } }
public function getResult() { $connectionDB = ConnectionDB::getInstance(); $mysqli = $connectionDB::connect(); $table = 'math_correct_answers'; $allAnswers = array(); $query = Mysqli_query($mysqli, "\n SELECT `sum_id`, `answer` FROM {$table}\n "); while ($row = mysqli_fetch_assoc($query)) { $allAnswers[$row['sum_id']] = $row['answer']; } $resultArray = array_intersect_assoc($allAnswers, $_SESSION['answers']); $data = array(); $data['correctAnswers'] = count($resultArray); $data['allAnswers'] = count($allAnswers); $data = json_encode($data); echo $data; }
public function deleteSum() { $connectionDB = ConnectionDB::getInstance(); $mysqli = $connectionDB::connect(); $id = $_POST['id']; $response = ''; $query = Mysqli_query($mysqli, "DELETE FROM math_sums WHERE id = " . $id); if ($query) { $response .= 'Deleted test ' . $id . 'from math_sums. '; } else { exit(mysqli_error($mysqli)); } $query = Mysqli_query($mysqli, "DELETE FROM math_correct_answers WHERE sum_id = " . $id); if ($query) { $response .= 'Deleted test ' . $id . 'from math_correct_answers. '; } else { exit(mysqli_error($mysqli)); } echo $response; }
public static function updateMoney($idUser, $idMoney, $price) { $pdo = ConnectionDB::getInstance()->getDB(); $command = "INSERT INTO dp_history_money (price,id_money,id_user) VALUES(?,?,?)"; $sentencia = $pdo->prepare($command); $sentencia->bindParam(1, $price); $sentencia->bindParam(2, $idMoney); $sentencia->bindParam(3, $idUser); $sentencia->execute(); return $sentencia->rowCount(); }
public static function getUserByUsername($username) { $comando = "SELECT " . self::USERNAME . "," . self::PASSWORD . "," . self::API_KEY . " FROM " . self::NAME_TABLE . " WHERE " . self::USERNAME . "=?"; $sentencia = ConnectionDB::getInstance()->getDB()->prepare($comando); $sentencia->bindParam(1, $username); if ($sentencia->execute()) { return $sentencia->fetch(PDO::FETCH_ASSOC); } else { return null; } }
public static function change_position($id1, $id2) { $pdo = ConnectionDB::getInstance()->getDB(); $command = "UPDATE " . self::NAME_TABLE . " t1, " . self::NAME_TABLE . " t2 SET t1." . self::POSITION . "=t2." . self::POSITION . ", t2." . self::POSITION . "=t1." . self::POSITION . " WHERE t1." . self::ID_PRODUCT . "=? and t2." . self::ID_PRODUCT . "=?"; $sentencia = $pdo->prepare($command); $sentencia->bindParam(1, $id1); $sentencia->bindParam(2, $id2); $sentencia->execute(); return $sentencia->rowCount(); }