0

我希望同一个查询使用准备好的语句运行两次,但不能让它工作?

这是我得到的:

$yearFrom = date("Y-01-01");
$yearTo = date("Y-12-31");

$monthFrom = date("Y-01-01");
$monthTo = date("Y-01-31");

$stmt = $mysqli->stmt_init();

$getuserpoints = "SELECT SUM(points) as userpoints FROM ".$prefix."_publicpoints
                    WHERE date BETWEEN ? AND ? AND fk_player_id = ?";

if($stmt->prepare($getuserpoints)){
    $stmt->bind_param('ssi', $yearFrom,$yearTo,$playerid);
    $stmt->execute();
    if (!$stmt->execute()) {
        echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
    }
    $stmt->bind_result($userPoints);

    $stmt->bind_param('ssi', $monthFrom,$monthTo,$playerid);
    $stmt->execute();
    if (!$stmt->execute()) {
        echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
    }
    $stmt->bind_result($userMPoints);
} 

我认为是造成麻烦的日期时间。我该怎么做呢?

提前致谢 :-)

4

0 回答 0