Skip to content

Commit 69f0b2d

Browse files
committed
feat(legacy-create-video): [golden-master] remove update
1 parent 507f63c commit 69f0b2d

File tree

1 file changed

+19
-19
lines changed
  • exercises/legacy_create_video/solutions/codely_php-symfony_golden-master/src/AppBundle/Controller

1 file changed

+19
-19
lines changed

exercises/legacy_create_video/solutions/codely_php-symfony_golden-master/src/AppBundle/Controller/VideoController.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,24 @@ class VideoController extends BaseController
1717
public function postVideoAction(Request $request)
1818
{
1919
// Preparing the sql to create the video
20+
$title = $request->get('title');
21+
$url = $request->get('url');
22+
$courseId = $request->get('course_id');
23+
24+
if (strpos($title, "hexagonal")) {
25+
$title = str_replace("hexagonal", "Hexagonal", $title);
26+
}
27+
if (strpos($title, "solid")) {
28+
$title = str_replace("solid", "SOLID", $title);
29+
}
30+
if (strpos($title, "tdd")) {
31+
$title = str_replace("tdd", "TDD", $title);
32+
}
33+
2034
$sql = "INSERT INTO video (title, url, course_id)
21-
VALUES (\"{$request->get('title')}\",
22-
\"{$request->get('url')}\",
23-
{$request->get('course_id')}
35+
VALUES (\"{$title}\",
36+
\"{$url}\",
37+
{$courseId}
2438
)";
2539

2640
// Prepare doctrine statement
@@ -31,26 +45,12 @@ public function postVideoAction(Request $request)
3145
// IMPORTANT: Obtaining the video id. Take care, it's done without another query :)
3246
$videoId = $connection->lastInsertId();
3347

34-
$title = $request->get('title');
35-
$sql = "UPDATE video SET ";
36-
if (strpos($request->get('title'), "hexagonal")) {
37-
$title = str_replace("hexagonal", "Hexagonal", $title);
38-
}
39-
if (strpos($request->get('title'), "solid")) {
40-
$title = str_replace("solid", "SOLID", $title);
41-
}
42-
if (strpos($request->get('title'), "tdd")) {
43-
$title = str_replace("tdd", "TDD", $title);
44-
}
45-
$sql .= "title = '" . $title . "' WHERE id = " . $videoId;
46-
$connection->query($sql);
47-
4848
// And we return the video created
4949
return [
5050
'id' => $videoId,
5151
'title' => $title,
52-
'url' => $request->get('url'),
53-
'course_id' => $request->get('course_id'),
52+
'url' => $url,
53+
'course_id' => $courseId,
5454
];
5555
}
5656
}

0 commit comments

Comments
 (0)