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;
|
namespace Slovocast\Domain\Repository\Channel;
|
||||||
|
|
||||||
@ -95,9 +95,11 @@ class ChannelRepository implements ChannelRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function create(Channel $channel, User $owner): int
|
public function create(Channel $channel, User $owner): int
|
||||||
{
|
{
|
||||||
$query = "INSERT INTO channels (name, slug, description, link,
|
$query = <<<SQL
|
||||||
|
INSERT INTO channels (name, slug, description, link,
|
||||||
language, copyright, explicit, owner_id)
|
language, copyright, explicit, owner_id)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
SQL;
|
||||||
|
|
||||||
$results = await($this->db->query($query, [
|
$results = await($this->db->query($query, [
|
||||||
$channel->getName(),
|
$channel->getName(),
|
||||||
@ -120,13 +122,16 @@ class ChannelRepository implements ChannelRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function update(Channel $channel): bool
|
public function update(Channel $channel): bool
|
||||||
{
|
{
|
||||||
$query = "UPDATE channels SET name = ?,
|
$query = <<<SQL
|
||||||
|
UPDATE channels SET name = ?,
|
||||||
slug = ?,
|
slug = ?,
|
||||||
description = ?,
|
description = ?,
|
||||||
link = ?,
|
link = ?,
|
||||||
language = ?,
|
language = ?,
|
||||||
copyright = ?,
|
copyright = ?,
|
||||||
explicit = ?";
|
explicit = ?
|
||||||
|
WHERE id = ?;
|
||||||
|
SQL;
|
||||||
|
|
||||||
$results = await($this->db->query($query, [
|
$results = await($this->db->query($query, [
|
||||||
$channel->getName(),
|
$channel->getName(),
|
||||||
@ -136,6 +141,7 @@ class ChannelRepository implements ChannelRepositoryInterface
|
|||||||
$channel->getLanguage(),
|
$channel->getLanguage(),
|
||||||
$channel->getCopyright(),
|
$channel->getCopyright(),
|
||||||
$channel->isExplicit(),
|
$channel->isExplicit(),
|
||||||
|
$channel->getId(),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
return (bool) $results->affectedRows;
|
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/
|
- slovocast_db:/var/lib/mysql/data/
|
||||||
app:
|
app:
|
||||||
build:
|
build:
|
||||||
content: .
|
context: .
|
||||||
dockerfile: deploy/php/Dockerfile
|
dockerfile: deploy/php/Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
|
Loading…
Reference in New Issue
Block a user