This is my 'method' of Placing Bets on my betting system.
In this method, I register data in two tables, a BET call and another BET_MATCHES, the system is controlled by time, so in all the registers I need to set the TIME_ZONE = '-03: 00' to make sure it does not there will be no error in the time, and after that execute the query that registers the header and generates the bet ID.
But when I retrieve the last id generated in this multi_query, the code returns me = 0 ... what can I do?
public function setBet($punter_name, $punter_phone, $value, $colab_id, $array_matches)
{
// Post Header and Catch Bet ID
$query = "SET TIME_ZONE = '-03:00';";
$query .= "INSERT INTO bet SET id ='NULL',
punter_name ='$punter_name',
punter_phone ='$punter_phone',
value ='$value',
colab_id ='$colab_id',
date_time = now()";
$data = mysqli_multi_query(Conexao::conectar(), $query) or die(Conexao::conectar());
// For if data True, registered Header
if ($data){
// Get the id what we want
$query = "SELECT LAST_INSERT_ID() FROM bet";
$data = mysqli_query(Conexao::conectar(), $query);
$line = mysqli_fetch_assoc($data);
var_dump($line);
}
else
echo "There was an error when registering the bet header";
}