From a924590dd6edb653cc82966ad9a5dfb26c05f568 Mon Sep 17 00:00:00 2001 From: Joan Miquel Date: Sun, 24 Jan 2021 00:36:38 +0100 Subject: [PATCH] Kumbiaphp clean (#6315) * Clean Kumbiaphp workerman raw * Clean dockerfiles --- .../bench/app/controllers/ku_controller.php | 14 +++++++------- frameworks/PHP/kumbiaphp/bench/app/libs/ku_raw.php | 7 +++---- frameworks/PHP/kumbiaphp/kumbiaphp-raw.dockerfile | 3 ++- frameworks/PHP/kumbiaphp/kumbiaphp.dockerfile | 3 ++- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/frameworks/PHP/kumbiaphp/bench/app/controllers/ku_controller.php b/frameworks/PHP/kumbiaphp/bench/app/controllers/ku_controller.php index 4c19fa3676a..0c545d23794 100644 --- a/frameworks/PHP/kumbiaphp/bench/app/controllers/ku_controller.php +++ b/frameworks/PHP/kumbiaphp/bench/app/controllers/ku_controller.php @@ -13,8 +13,8 @@ protected function before_filter() public function index() { - KuRaw::$db->execute([mt_rand(1, 10000)]); - echo json_encode(KuRaw::$db->fetch()); + KuRaw::$random->execute([mt_rand(1, 10000)]); + echo json_encode(KuRaw::$random->fetch()); } public function query($count = 1) @@ -22,8 +22,8 @@ public function query($count = 1) $count = min(max((int) $count, 1), 500); while ($count--) { - KuRaw::$db->execute([mt_rand(1, 10000)]); - $worlds[] = KuRaw::$db->fetch(); + KuRaw::$random->execute([mt_rand(1, 10000)]); + $worlds[] = KuRaw::$random->fetch(); } echo json_encode($worlds); } @@ -33,14 +33,14 @@ public function update($count = 1) $count = min(max((int) $count, 1), 500); while ($count--) { - $id = mt_rand(1, 10000); - KuRaw::$random->execute([$id]); - $row = ['id' => $id, 'randomNumber' => KuRaw::$random->fetchColumn()]; + KuRaw::$random->execute([mt_rand(1, 10000)]); + $row = KuRaw::$random->fetch(); $row['randomNumber'] = mt_rand(1, 10000); $worlds[] = $row; } + KuRaw::update($worlds); echo json_encode($worlds); diff --git a/frameworks/PHP/kumbiaphp/bench/app/libs/ku_raw.php b/frameworks/PHP/kumbiaphp/bench/app/libs/ku_raw.php index a691f364011..7e038d4fe87 100644 --- a/frameworks/PHP/kumbiaphp/bench/app/libs/ku_raw.php +++ b/frameworks/PHP/kumbiaphp/bench/app/libs/ku_raw.php @@ -24,7 +24,6 @@ public static function init() ] ); - self::$db = $pdo->prepare('SELECT id,randomNumber FROM World WHERE id = ?'); self::$fortune = $pdo->prepare('SELECT id,message FROM Fortune'); self::$random = $pdo->prepare('SELECT id,randomNumber FROM World WHERE id = ?'); self::$instance = $pdo; @@ -42,9 +41,9 @@ public static function update(array $worlds) if (!isset(self::$update[$rows])) { $sql = 'UPDATE world SET randomNumber = CASE id' - . str_repeat(' WHEN ?::INTEGER THEN ?::INTEGER ', $rows) . - 'END WHERE id IN (' - . implode(', ', array_fill(0, $rows, '?::INTEGER')) . ')'; + . str_repeat(' WHEN ?::INTEGER THEN ?::INTEGER ', $rows) + . 'END WHERE id IN (' + . str_repeat('?::INTEGER,', $rows - 1) . '?::INTEGER)'; self::$update[$rows] = self::$instance->prepare($sql); } diff --git a/frameworks/PHP/kumbiaphp/kumbiaphp-raw.dockerfile b/frameworks/PHP/kumbiaphp/kumbiaphp-raw.dockerfile index 3bcb46bd48a..0bce6ecdb3b 100644 --- a/frameworks/PHP/kumbiaphp/kumbiaphp-raw.dockerfile +++ b/frameworks/PHP/kumbiaphp/kumbiaphp-raw.dockerfile @@ -5,7 +5,8 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php RUN apt-get update -yqq > /dev/null && \ - apt-get install -yqq nginx git unzip php8.0 php8.0-common php8.0-cli php8.0-fpm php8.0-mysql > /dev/null + apt-get install -yqq nginx git unzip \ + php8.0-fpm php8.0-mysql > /dev/null COPY deploy/conf/* /etc/php/8.0/fpm/ diff --git a/frameworks/PHP/kumbiaphp/kumbiaphp.dockerfile b/frameworks/PHP/kumbiaphp/kumbiaphp.dockerfile index fd3421563ac..8701b2db3f6 100644 --- a/frameworks/PHP/kumbiaphp/kumbiaphp.dockerfile +++ b/frameworks/PHP/kumbiaphp/kumbiaphp.dockerfile @@ -5,7 +5,8 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php RUN apt-get update -yqq > /dev/null && \ - apt-get install -yqq nginx git unzip php8.0 php8.0-common php8.0-cli php8.0-fpm php8.0-mysql > /dev/null + apt-get install -yqq nginx git unzip \ + php8.0-fpm php8.0-mysql > /dev/null COPY deploy/conf/* /etc/php/8.0/fpm/