Full implemantation

This commit is contained in:
2022-11-28 22:56:21 -03:00
parent 30ef4c6a35
commit c53eb4c7a6
55 changed files with 1505 additions and 1011 deletions

View File

@ -2,6 +2,7 @@
namespace ProVM\Common\Implement;
use PDO;
use PDOException;
use ProVM\Common\Exception\Database\BlankResult;
use Psr\Log\LoggerInterface;
use ProVM\Common\Define\Model as ModelInterface;
@ -64,10 +65,10 @@ abstract class Repository
$old_values = $this->valuesForUpdate($old);
$columns = [];
$values = [];
foreach ($this->fieldsForUpdate() as $column => $method) {
if (isset($model_values[$column]) and $old_values[$column] !== $model_values[$column]) {
$columns []= "`{$column}`";
$values []= $model_values[$column];
foreach ($this->fieldsForUpdate() as $i => $column) {
if (isset($model_values[$i]) and $old_values[$i] !== $model_values[$i]) {
$columns []= "`{$column}` = ?";
$values []= $model_values[$i];
}
}
if (count($columns) === 0) {
@ -101,8 +102,9 @@ abstract class Repository
} catch (BlankResult $e) {
$this->insert($model);
$model->setId($this->getConnection()->lastInsertId());
} catch (\Error | \Exception $e) {
} catch(PDOException $e) {
$this->getLogger()->error($e);
throw $e;
}
}
abstract public function load(array $row): ModelInterface;