/** * Handles the incrementing of a key's API hits. * Returns false if the user's key has maxed out hits for the day * @param string $API_key * @param string $API_hit_date * @return void/false */ public function update_API_hits($API_key, $API_hit_date) { //if the api has already been hit today if (date('Ymd') == date('Ymd', strtotime($API_hit_date))) { //make sure that the key hasn't hit its limit. //if it has return false if (!$this->call_limit_reached($API_key)) { $query = "UPDATE " . Database::$users_table . " SET " . $this->API_hit_count_column_name . "=" . $this->API_hit_count_column_name . "+1 WHERE " . $this->API_key_column_name . "='" . $API_key . "'"; Database::execute_sql($query); } else { return false; } } else { //if the API has not been hit today set the hits to zero and the hit date to today $now = new DateTime(); $query = "UPDATE " . Database::$users_table . " SET " . $this->API_hit_count_column_name . " = 0, " . $this->API_hit_date_column_name . "='" . $now->format(DateTime::ISO8601) . "' WHERE " . $this->API_key_column_name . "='" . $API_key . "'"; Database::execute_sql($query); } }