la connexion mysql devien globale à tout le site (finalement j'aurai plusieurs appels par page)
This commit is contained in:
parent
6660a9965c
commit
3bf8d8ce55
|
@ -13,7 +13,7 @@
|
||||||
@session_start();
|
@session_start();
|
||||||
|
|
||||||
require_once("../src/functions.php");
|
require_once("../src/functions.php");
|
||||||
|
$lnMysql=conn_bdd();
|
||||||
$arenas=get_arenas_list();
|
$arenas=get_arenas_list();
|
||||||
$lang=get_language_array();
|
$lang=get_language_array();
|
||||||
|
|
||||||
|
|
|
@ -112,8 +112,9 @@ function conn_bdd(){
|
||||||
|
|
||||||
}
|
}
|
||||||
function get_battles_history($game){
|
function get_battles_history($game){
|
||||||
|
global $lnMysql;
|
||||||
$game=substr($game,0,8); //limit 8 char for limitting mysql index size
|
$game=substr($game,0,8); //limit 8 char for limitting mysql index size
|
||||||
$lnMysql=conn_bdd();
|
|
||||||
$rs=mysqli_query($lnMysql,
|
$rs=mysqli_query($lnMysql,
|
||||||
" SELECT
|
" SELECT
|
||||||
player1.name,
|
player1.name,
|
||||||
|
@ -142,15 +143,16 @@ function get_battles_history($game){
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
mysqli_close($lnMysql);
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
function save_battle($game,$bot1,$bot2,$resultat){
|
function save_battle($game,$bot1,$bot2,$resultat){
|
||||||
//resultat: 0 match nul, 1 bot1 gagne 2 bot 2 gagne
|
//resultat: 0 match nul, 1 bot1 gagne 2 bot 2 gagne
|
||||||
|
|
||||||
|
global $lnMysql;
|
||||||
|
|
||||||
$game=substr($game,0,8); //limit 8 char for limitting mysql index size
|
$game=substr($game,0,8); //limit 8 char for limitting mysql index size
|
||||||
|
|
||||||
$lnMysql=conn_bdd();
|
|
||||||
//chercher les id de bot 1 et bot2
|
//chercher les id de bot 1 et bot2
|
||||||
$rs=mysqli_query($lnMysql,"SELECT name,id FROM bots
|
$rs=mysqli_query($lnMysql,"SELECT name,id FROM bots
|
||||||
WHERE name='".mysqli_real_escape_string($lnMysql,$bot1)."'
|
WHERE name='".mysqli_real_escape_string($lnMysql,$bot1)."'
|
||||||
|
@ -186,6 +188,4 @@ function save_battle($game,$bot1,$bot2,$resultat){
|
||||||
'".$bots[$bot2]."',
|
'".$bots[$bot2]."',
|
||||||
'1')
|
'1')
|
||||||
ON DUPLICATE KEY UPDATE ".$field." = ".$field." + 1;");
|
ON DUPLICATE KEY UPDATE ".$field." = ".$field." + 1;");
|
||||||
|
|
||||||
mysqli_close($lnMysql);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user