-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
User can now generate baby reg link by clicking Share icon: #130
- Loading branch information
1 parent
91cc017
commit 691a223
Showing
8 changed files
with
204 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
class BabyRegistryToken extends Model{ | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
public function getAll(){ | ||
$stmt = self::$_connection->prepare("SELECT * FROM baby_registry_tokens"); | ||
$stmt->execute(); | ||
$stmt->setFetchMode(PDO::FETCH_CLASS, 'BabyRegistryToken'); | ||
return $stmt->fetchAll(); | ||
} | ||
|
||
public function find($token_id){ | ||
$stmt = self::$_connection->prepare("SELECT * FROM baby_registry_tokens WHERE token_id = :token_id"); | ||
$stmt->execute(['token_id'=>$token_id]); | ||
$stmt->setFetchMode(PDO::FETCH_CLASS, 'BabyRegistryToken'); | ||
return $stmt->fetch(); | ||
} | ||
|
||
public function findByBabyRegistryId($baby_registry_id){ | ||
$stmt = self::$_connection->prepare("SELECT * FROM baby_registry_tokens WHERE baby_registry_id = :baby_registry_id"); | ||
$stmt->execute(['baby_registry_id'=>$baby_registry_id]); | ||
$stmt->setFetchMode(PDO::FETCH_CLASS, 'BabyRegistryToken'); | ||
return $stmt->fetch(); | ||
} | ||
|
||
public function insert(){ | ||
$stmt = self::$_connection->prepare("INSERT INTO baby_registry_tokens(baby_registry_id, token, status) VALUES(:baby_registry_id, :token, :status)"); | ||
$stmt->execute(['baby_registry_id'=>$this->baby_registry_id, | ||
'token'=>$this->token, | ||
'status'=>$this->status]); | ||
$_SESSION['updated_address_id'] = self::$_connection->lastInsertId(); | ||
} | ||
|
||
public function delete(){ | ||
$stmt = self::$_connection->prepare("DELETE FROM baby_registry_tokens WHERE brand_id = :brand_id"); | ||
$stmt->execute(['brand_id'=>$this->brand_id]); | ||
} | ||
|
||
public function updateStatus(){ | ||
$stmt = self::$_connection->prepare("UPDATE baby_registry_tokens SET brand_name = :brand_name WHERE brand_id = :brand_id"); | ||
$stmt->execute(['brand_name'=>$this->brand_name, | ||
'brand_id'=>$this->brand_id]); | ||
} | ||
|
||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.