--$conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
--$conn -> query("SET NAMES utf8");
++$conn = new PDO(
++ "mysql:host=$host;dbname=$dbname",
++ $username,
++ $password
++ [
++ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
++ PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'",
++ ],
++);
--$err = $conn -> query("INSERT INTO RECIPE(recipe_id,aspect_ratio,yields,cook_time_minutes,country,descriptions,prep_time_minutes,total_time_minutes,name,thumnai_url) VALUES('$id','$asp','$yie','$c_t_m','$country','$desc','$p_t_m','$t_t_m','$name','$t_url')");
--echo "\nrec PDOStatement::errorCode(): ";
--print $err->errorCode();
++$req = $conn->prepare(<<<REQ
++ INSERT INTO RECIPE (
++ recipe_id, aspect_ratio, yields, cook_time_minutes, country, descriptions,
++ prep_time_minutes,total_time_minutes,name,thumnai_url
++ ) VALUES (
++ :recipe_id, :aspect_ratio, :yields, :cook_time_minutes, :country, :descriptions,
++ :prep_time_minutes, :total_time_minutes, :name, :thumnai_url
++ )
++REQ);
++$req->execute([
++ 'recipe_id' => $data['id'],
++ 'aspect_ratio' => $data['aspectRatio'],
++ 'yields' => $data['yields'],
++ 'cook_time_minutes' => $data['cookTimeMinutes'],
++ 'country' => $data['country'],
++ 'descriptions' => $data['description'],
++ 'prep_time_minutes' => $data['prepTimeMinutes'],
++ 'total_time_minutes' => $data['totalTimeMinutes'],
++ 'name' => $data['name'],
++ 'thumnai_url' => $data['thumbnailUrl'],
++]);
SELECT Images.Path_img, Product.Name, Description.Small_desc, Product.Name
FROM `Images`
JOIN `Product`
JOIN `Description`
JOIN `Popular_product` ON Popular_product.ID_regularProduct = Product.ID;
SELECT `d`.`generation_id`, `d`.`Name`, `d`.`volume`, `d`.`capacity`,
`d`.`type_of_connector`, COUNT(DISTINCT `c`.`color_id`) AS `color_count`
FROM `device` AS `d`
JOIN `device2color_body` AS `c` ON `c`.`device_id` = `d`.`id`
GROUP BY `d`.`generation_id`, `d`.`Name`, `d`.`volume`, `d`.`capacity`,
`d`.`type_of_connector`
SELECT `generation_id`, `Name`, COUNT(*) AS `count`
FROM (
SELECT DISTINCT `d`.`generation_id`, `d`.`Name`, `d`.`volume`, `d`.`capacity`,
`d`.`type_of_connector`, `c`.`color_id`
FROM `device` AS `d`
JOIN `device2color_body` AS `c` ON `c`.`device_id` = `d`.`id`
) AS `t`
GROUP BY `generation_id`, `Name`
WITH `cte` (`id`) AS (
SELECT `ID`
FROM `Orders`
ORDER BY `ID` DESC
LIMIT 3
)
SELECT DISTINCT `op`.`Code`
FROM `cte`
JOIN `OrdersProducts` AS `op`
ON `op`.`OrderID` = `cte`.`id`
SELECT DISTINCT `op`.`Code`
FROM (
SELECT `ID`
FROM `Orders`
ORDER BY `ID` DESC
LIMIT 3
) AS `o`
JOIN `OrdersProducts` AS `op`
ON `op`.`OrderID` = `o`.`id`
SELECT DISTINCT `Code`
FROM `OrdersProducts`
WHERE `OrderID` IN (
SELECT `ID`
FROM `Orders`
ORDER BY `ID` DESC
LIMIT 3
)
SELECT DISTINCT FIRST_VALUE(`id`) OVER `win` AS `id`, `user_id`,
FIRST_VALUE(`score`) OVER `win` AS `score`,
FIRST_VALUE(`user_name`) OVER `win` AS `user_name`
FROM `game_api_score`
WINDOW `win` AS (PARTITION BY `user_id` ORDER BY `score` DESC)