public function propose_badminton_date(ProposedDate $badminton_date) { /* (Children of ProposedDate) -> BadmintonDate Attempts to create a new badminton date into the database, assumes sanitized input already */ if ((strtotime($badminton_date->begin_datetime) > time()) && (strtotime($badminton_date->end_datetime) > time())) { $sql = "INSERT INTO badminton_dates (datename, begin_datetime, end_datetime, creator_id, confirmed, summary) VALUES ('$badminton_date->datename', '$badminton_date->begin_datetime', '$badminton_date->end_datetime', '$this->user_id', '" . BadmintonDate::CONFIRMED . "', '$badminton_date->summary') ON DUPLICATE KEY UPDATE date_id = date_id"; $result = $this->dbc->query($sql) or die ($this->dbc->error); if (($this->dbc->affected_rows == 2) || ($this->dbc->affected_rows == 0)) { //Update was preformed $sql = "SELECT date_id FROM `badminton_dates` WHERE begin_datetime = '$badminton_date->begin_datetime' AND end_datetime = '$badminton_date->end_datetime'"; $result = $this->dbc->query($sql) or die ($this->dbc->error); $badminton_date->date_id = mysqli_fetch_row($result)[0]; } else { //Join the badminton date $badminton_date->date_id = $this->dbc->insert_id; //Push the action $action = new ProposeBadmintonDate(array( 'proposer' => clone $this, 'badminton_date' => $badminton_date) ); ActionPusher::push_action($action); $this->join_badminton_date($badminton_date); //Create the badminton conversation ConversationFactory::generate_conversation($badminton_date); } return $badminton_date; } else { throw new UnexpectedValueException('UnexpectedValueException occured on request on the method call propose_badminton_date'); return false; } }