Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * , du tar tiden ved å kjøre microtime() før og etter og måler forskjellen
- 16:31 <@echofish> så kjedelig du er
- 16:31 <@AlecTBM> altså $newtime-$oldtime
- *
- * */
- try {
- $debug = "true";
- require_once('db.php');
- $dbh = new PDO($dbd, $dbu, $dbp);
- $dbh->beginTransaction();
- $stmt = $dbh->prepare("SELECT * FROM `looking` LIMIT 2");
- $stmt->bindParam(':s', $session, PDO::PARAM_STR);
- dump("stmex-execute-select-players",$stmt->execute());
- $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
- dump("result-select-players",$result);
- if(count($result) == 2) {
- dump("result-two",$result);
- echo "count 2";
- $sql = "INSERT INTO `rag`.`players` (`sess` ,`targetIP` ,`targetPORT`, `accepted`) ";
- $sql .="VALUES (:s, :i, :p, 0)";
- $stmt = $dbh->prepare($sql);
- $stmt->bindParam(':s', $result[0]['sess'], PDO::PARAM_STR);
- $stmt->bindParam(':i', $result[1]['IP'], PDO::PARAM_STR);
- $stmt->bindParam(':p', $result[1]['PORT'], PDO::PARAM_STR);
- dump("stmex-execute-insert-player-0",$stmt->execute());
- $stmt = $dbh->prepare($sql);
- $stmt->bindParam(':s', $result[1]['sess'], PDO::PARAM_STR);
- $stmt->bindParam(':i', $result[0]['IP'], PDO::PARAM_STR);
- $stmt->bindParam(':p', $result[0]['PORT'], PDO::PARAM_STR);
- dump("stmex-execute-insert-player-1",$stmt->execute());
- $sql = "DELETE FROM `rag`.`looking` WHERE `looking`.`sess` = :sone OR `looking`.`sess` = :stwo LIMIT 2";
- $stmt = $dbh->prepare($sql);
- $stmt->bindParam(':sone', $result[0]['sess'], PDO::PARAM_STR);
- $stmt->bindParam(':stwo', $result[1]['sess'], PDO::PARAM_STR);
- dump("stmex-execute-delete-player-0-and-1",$stmt->execute());
- } else {
- dump("result-not",$result);
- echo "count !2";
- }
- $dbh->commit();
- } catch (PDOException $e)
- {
- $dbh->rollBack();
- fail_and_die('exception: '.$e->getMessage());
- }
- function dump($msg, $var) {
- global $debug;
- if($debug == "true") {
- echo "<br><br>$msg<pre>";
- var_dump($var);
- echo "</pre>";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement