I believe it could add a nice touch to implement an abstract class as a Driver helper.
Something like this:
<?php
namespace XHGui\Db;
abstract class PdoDriverAbstract
{
/* @var PdoDriverAbstract */
private $driver;
public function __construct(string $driverName)
{
switch($driverName)
{
case "mysql":
$this->driver = new PdoMysqlDriver();
break;
default:
$this->driver = new PdoSqliteDriver();
}
}
abstract public function getTableQuery(): string;
}
Then we could do something like this:
public function __construct(PDO $pdo, string $driverName, string $table, string $tableWatch)
{
$this->pdo = $pdo;
$this->driver = new PdoDriverAbstract($driverName);
$this->table = sprintf('"%s"', $table);
$this->tableWatches = sprintf('"%s"', $tableWatch);
$this->initSchema();
}
public function initSchema(): void
{
$this->pdo->exec($this->driver->getTableQuery()
', $this->table));
...
}
It would be ready to scale if other exception happens in the futur...but then its a bit overkill for now.
Problem
mysql driver truncate data when using field type
TEXT
while exceeding 65535 charactersSolution
Use field type
LONGTEXT
when using mysql driver.Related PR
Alternative
I believe it could add a nice touch to implement an abstract class as a Driver helper. Something like this:
Then we could do something like this:
It would be ready to scale if other exception happens in the futur...but then its a bit overkill for now.
Let me know !