Use long line strings for big queries and start the connection abstracts.
This commit is contained in:
parent
7b64e688be
commit
7f05554f4e
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php /** @noinspection ALL */
|
||||
|
||||
namespace Slovocast\Domain\Repository\Channel;
|
||||
|
||||
@ -95,9 +95,11 @@ class ChannelRepository implements ChannelRepositoryInterface
|
||||
*/
|
||||
public function create(Channel $channel, User $owner): int
|
||||
{
|
||||
$query = "INSERT INTO channels (name, slug, description, link,
|
||||
language, copyright, explicit, owner_id)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
$query = <<<SQL
|
||||
INSERT INTO channels (name, slug, description, link,
|
||||
language, copyright, explicit, owner_id)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
SQL;
|
||||
|
||||
$results = await($this->db->query($query, [
|
||||
$channel->getName(),
|
||||
@ -120,13 +122,16 @@ class ChannelRepository implements ChannelRepositoryInterface
|
||||
*/
|
||||
public function update(Channel $channel): bool
|
||||
{
|
||||
$query = "UPDATE channels SET name = ?,
|
||||
slug = ?,
|
||||
description = ?,
|
||||
link = ?,
|
||||
language = ?,
|
||||
copyright = ?,
|
||||
explicit = ?";
|
||||
$query = <<<SQL
|
||||
UPDATE channels SET name = ?,
|
||||
slug = ?,
|
||||
description = ?,
|
||||
link = ?,
|
||||
language = ?,
|
||||
copyright = ?,
|
||||
explicit = ?
|
||||
WHERE id = ?;
|
||||
SQL;
|
||||
|
||||
$results = await($this->db->query($query, [
|
||||
$channel->getName(),
|
||||
@ -136,6 +141,7 @@ class ChannelRepository implements ChannelRepositoryInterface
|
||||
$channel->getLanguage(),
|
||||
$channel->getCopyright(),
|
||||
$channel->isExplicit(),
|
||||
$channel->getId(),
|
||||
]));
|
||||
|
||||
return (bool) $results->affectedRows;
|
||||
|
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Slovocast\Infrastructure\Api\Database;
|
||||
|
||||
interface ConnectionInterface
|
||||
{
|
||||
public function release(): void;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Slovocast\Infrastructure\Api\Database;
|
||||
|
||||
interface ConnectionPoolInterface
|
||||
{
|
||||
public function getTotalConnectionCount(): int;
|
||||
public function hasFreeConnection(): bool;
|
||||
public function getConnection(): ConnectionInterface;
|
||||
public function releaseConnection(ConnectionInterface $connection): void;
|
||||
}
|
@ -14,7 +14,7 @@ services:
|
||||
- slovocast_db:/var/lib/mysql/data/
|
||||
app:
|
||||
build:
|
||||
content: .
|
||||
context: .
|
||||
dockerfile: deploy/php/Dockerfile
|
||||
ports:
|
||||
- "8000:8000"
|
||||
|
Loading…
Reference in New Issue
Block a user