Skip to content

Commit

Permalink
added date to bouquet concept
Browse files Browse the repository at this point in the history
  • Loading branch information
kiw808 committed May 5, 2020
1 parent 3d08dc8 commit 7631448
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 44 deletions.
91 changes: 51 additions & 40 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/Controller/ConceptController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Model\ConceptManager;
use App\Model\CatalogueUManager;
use App\Model\BouquetCatManager;
use DateTime;

/**
* Class ConceptController
Expand Down Expand Up @@ -37,11 +38,12 @@ public function index()
*/
public function create()
{

$conceptManager = new ConceptManager();
$date = new DateTime("now");
$concept = [
'id_user' => $_POST['id_user'],
'id_panier' => $_POST['id_panier'],
'date' => $date->format('Y-m-d')
];
$_SESSION['user'] = $concept['id_user'];
$id = $conceptManager->insert($concept);
Expand All @@ -64,6 +66,10 @@ public function show(int $id)
{
$conceptManager = new ConceptManager();

if (!isset($_SESSION['id_bouquet_concept'])) {
$_SESSION['id_bouquet_concept'] = $id;
}

if ($id != $_SESSION['id_bouquet_concept']) {
$_SESSION['id_bouquet_concept'] = $id;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Model/ConceptManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ public function showConcept($id)
public function insert(array $concept)
{
$statement = $this->pdo->prepare("INSERT INTO " . self::TABLE . "
VALUES (NULL, :id_user, :id_panier, NULL, NULL)");
$statement->bindValue('id_user', $concept['id_user'], \PDO::PARAM_INT);
$statement->bindValue('id_panier', $concept['id_panier'], \PDO::PARAM_INT);
VALUES (NULL, :id_user, :id_panier, NULL, NULL, :date)");
$statement->bindValue(':id_user', $concept['id_user'], \PDO::PARAM_INT);
$statement->bindValue(':id_panier', $concept['id_panier'], \PDO::PARAM_INT);
$statement->bindValue(':date', $concept['date'], \PDO::PARAM_STR);

if ($statement->execute()) {
return (int)$this->pdo->lastInsertId();
Expand Down

0 comments on commit 7631448

Please sign in to comment.