Skip to content

Commit d09d36a

Browse files
version 1.5.1
1 parent 8b9cf1c commit d09d36a

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/Repository/NoteRepository.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,16 @@ public function createNote(\App\Entity\Note $note): \App\Entity\Note
9797

9898
$query = '
9999
INSERT INTO `notes`
100-
(`name`, `description`)
100+
(`name`, `description`, `created_at`)
101101
VALUES
102-
(:name, :description)
102+
(:name, :description, :created_at)
103103
';
104104
$statement = $this->database->prepare($query);
105105
$name = $note->getName();
106106
$desc = $note->getDescription();
107107
$statement->bindParam(':name', $name);
108108
$statement->bindParam(':description', $desc);
109+
$statement->bindParam('created_at', date('Y-m-d H:i:s'));
109110
$data = $statement->execute();
110111

111112
if (!$data) {
@@ -122,7 +123,7 @@ public function updateNote(\App\Entity\Note $note): \App\Entity\Note
122123

123124
$query = '
124125
UPDATE `notes`
125-
SET `name` = :name, `description` = :description
126+
SET `name` = :name, `description` = :description, `updated_at` = :updated_at
126127
WHERE `id` = :id
127128
';
128129
$statement = $this->database->prepare($query);
@@ -132,6 +133,7 @@ public function updateNote(\App\Entity\Note $note): \App\Entity\Note
132133
$statement->bindParam(':id', $id);
133134
$statement->bindParam(':name', $name);
134135
$statement->bindParam(':description', $desc);
136+
$statement->bindParam('updated_at', date('Y-m-d H:i:s'));
135137
$data = $statement->execute();
136138

137139
if (!$data) {

src/Repository/TaskRepository.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,16 @@ public function create(object $task): object
110110

111111
$query = '
112112
INSERT INTO `tasks`
113-
(`name`, `description`, `status`, `userId`)
113+
(`name`, `description`, `status`, `userId`, `created_at`)
114114
VALUES
115-
(:name, :description, :status, :userId)
115+
(:name, :description, :status, :userId, :created_at)
116116
';
117117
$statement = $this->getDb()->prepare($query);
118118
$statement->bindParam('name', $task->name);
119119
$statement->bindParam('description', $task->description);
120120
$statement->bindParam('status', $task->status);
121121
$statement->bindParam('userId', $task->userId);
122+
$statement->bindParam('created_at', date('Y-m-d H:i:s'));
122123
$data = $statement->execute();
123124

124125
if (!$data) {
@@ -137,7 +138,7 @@ public function update(object $task): object
137138

138139
$query = '
139140
UPDATE `tasks`
140-
SET `name` = :name, `description` = :description, `status` = :status
141+
SET `name` = :name, `description` = :description, `status` = :status, `updated_at` = :updated_at
141142
WHERE `id` = :id AND `userId` = :userId
142143
';
143144
$statement = $this->getDb()->prepare($query);
@@ -146,6 +147,7 @@ public function update(object $task): object
146147
$statement->bindParam('description', $task->description);
147148
$statement->bindParam('status', $task->status);
148149
$statement->bindParam('userId', $task->userId);
150+
$statement->bindParam('updated_at', date('Y-m-d H:i:s'));
149151
$data = $statement->execute();
150152

151153
if (!$data) {

src/Repository/UserRepository.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,15 @@ public function create(object $user): object
126126

127127
$query = '
128128
INSERT INTO `users`
129-
(`name`, `email`, `password`)
129+
(`name`, `email`, `password`, `created_at`)
130130
VALUES
131-
(:name, :email, :password)
131+
(:name, :email, :password, :created_at)
132132
';
133133
$statement = $this->database->prepare($query);
134134
$statement->bindParam('name', $user->name);
135135
$statement->bindParam('email', $user->email);
136136
$statement->bindParam('password', $user->password);
137+
$statement->bindParam('created_at', date('Y-m-d H:i:s'));
137138
$data = $statement->execute();
138139

139140
if (!$data) {
@@ -149,12 +150,13 @@ public function update(object $user): object
149150
$this->database->beginTransaction();
150151

151152
$query = '
152-
UPDATE `users` SET `name` = :name, `email` = :email WHERE `id` = :id
153+
UPDATE `users` SET `name` = :name, `email` = :email, `updated_at` = :updated_at WHERE `id` = :id
153154
';
154155
$statement = $this->database->prepare($query);
155156
$statement->bindParam('id', $user->id);
156157
$statement->bindParam('name', $user->name);
157158
$statement->bindParam('email', $user->email);
159+
$statement->bindParam('updated_at', date('Y-m-d H:i:s'));
158160
$data = $statement->execute();
159161

160162
if (!$data) {

0 commit comments

Comments
 (0)