Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

42 строки
1.2KB

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Repositories;
  4. use Core\Repository;
  5. /**
  6. * Action codes: I Insert · U Update · D Delete · R Restore
  7. */
  8. class JobAuditRepository extends Repository
  9. {
  10. protected string $table = 'job_audit';
  11. protected string $primaryKey = 'audit_id';
  12. /** @param array<string, mixed> $fields */
  13. public function log(int $jobId, string $action, array $fields, string $username): void
  14. {
  15. $this->database->execute(
  16. "INSERT INTO job_audit (id, action, fields, username)
  17. VALUES (:id, :action, :fields, :username)",
  18. [
  19. 'id' => $jobId,
  20. 'action' => $action,
  21. 'fields' => json_encode($fields, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
  22. 'username' => $username,
  23. ]
  24. );
  25. }
  26. /** @return list<array<string, mixed>> */
  27. public function forRecord(int $jobId): array
  28. {
  29. return $this->database->query(
  30. 'SELECT audit_id, id, action, fields, username, created_at
  31. FROM job_audit WHERE id = :id ORDER BY audit_id ASC',
  32. ['id' => $jobId]
  33. );
  34. }
  35. }

Powered by TurnKey Linux.