コード例 #1
0
ファイル: User.php プロジェクト: stevenimle/GMA
 public function create(Chapter $_chapter, PledgeClass $_pledge_class, string $name_first, string $name_last, string $email_university, string $password, DateTime $date_started_university, bool $is_brother, string $email_alternate = "", string $phone_number = "", string $university_identifier = "", string $address_line_1 = "", string $address_line_2 = "", string $address_city = "", string $address_state = "", string $address_zip = "")
 {
     $this->_chapter = $_chapter;
     $this->_pledge_class = $_pledge_class;
     $query = "INSERT INTO `user`\n\t\t\t\t\t    (chapter_id, pledge_class_id, name_first, name_last, name_link, name_link_duplicate,\n\t\t\t\t\t     email_university, email_alternate, phone_number, university_identifier, address_line_1,\n\t\t\t\t\t     address_line_2, address_city, address_state, address_zip, date_started_university,\n\t\t\t\t\t     date_joined, password_hash, token_value_account_verify, token_expiry_account_verify,\n\t\t\t\t\t     is_brother)\n\t\t\t\t\t  SELECT\n\t\t\t\t\t    :cid, :pid, :nf, :nl, :nli, coalesce(max(name_link_duplicate) + 1, 0),\n\t\t\t\t\t    :eu, :ea, :pn, :uid, :adl1, :adl2, :adc, :ads, :adz, :ys, :tj, :ph, :tv, :te, :ib\n\t\t\t\t\t  FROM user\n\t\t\t\t\t  WHERE name_link = :nli AND chapter_id = :cid";
     $this->_pdo->perform($query, ["cid" => $this->chapter_id = $_chapter->getId(), "pid" => $this->pledge_class_id = $_pledge_class->getId(), "nf" => $this->name_first = $name_first, "nl" => $this->name_last = $name_last, "nli" => $this->name_link = Utility::getNameLink($name_last), "eu" => $this->email_university = $email_university, "ea" => $this->email_alternate = $email_alternate, "pn" => $this->phone_number = $phone_number, "uid" => $this->university_identifier = $university_identifier, "adl1" => $this->address_line_1 = $address_line_1, "adl2" => $this->address_line_2 = $address_line_2, "adc" => $this->address_city = $address_city, "ads" => $this->address_state = $address_state, "adz" => $this->address_zip = $address_zip, "ys" => $this->date_started_university = Utility::getDateTimeForMySQLDate($date_started_university), "tj" => $this->date_joined = Utility::getDateTimeForMySQLDate(), "ph" => $this->password_hash = Utility::hashPassword($password), "tv" => $this->token_value_account_verify = Utility::getRandomString(60), "te" => $this->token_expiry_account_verify = Utility::getExpiryAsMySQLDateTime("15 days"), "ib" => $this->is_brother = $is_brother]);
     $this->id = $this->_pdo->lastInsertId();
 }