20240719#1

This commit is contained in:
User
2024-07-19 13:38:34 +03:00
parent 858dfd17c0
commit 40e771f1f2
7 changed files with 23 additions and 18 deletions

View File

@@ -7,6 +7,8 @@ use Rmphp\Storage\Mysql\MysqlStorageInterface;
abstract class AbstractMysqlRepository extends AbstractRepository {
public const DEBUG = false;
public function __construct(
public readonly MysqlStorageInterface $mysql
) {}
@@ -21,7 +23,7 @@ abstract class AbstractMysqlRepository extends AbstractRepository {
$in = $this->getProperties($object, function ($value){
return (is_string($value)) ? $this->mysql->escapeStr($value) : $value;
});
//dd($object, $in);
if(static::DEBUG) dd($object, $in, $table);
try {
if (!empty($object->getId()) && !empty($this->mysql->findById($table, $object->getId()))) {
$this->mysql->updateById($table, $in, $object->getId());
@@ -32,8 +34,4 @@ abstract class AbstractMysqlRepository extends AbstractRepository {
}
} catch (\Throwable $throwable) {throw new RepositoryException($throwable->getMessage());}
}
}
}