TokenModel.php 797 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace Models;
  3. class TokenModel
  4. {
  5. private \PDO $pdo;
  6. public function __construct()
  7. {
  8. if (isset($GLOBALS['pdo']) && $GLOBALS['pdo'] instanceof \PDO) {
  9. $this->pdo = $GLOBALS['pdo'];
  10. return;
  11. }
  12. throw new \RuntimeException('Global PDO connection not initialized');
  13. }
  14. public function getByUf(string $uf): array
  15. {
  16. $stmt = $this->pdo->prepare('SELECT token_id, token_external_id, token_commodities_amount, token_commodities_value, token_uf, token_city, token_content, token_flag, wallet_id, chain_id, commodities_id, cpr_id, user_id FROM "token" WHERE token_uf = :uf ORDER BY token_id');
  17. $stmt->execute(['uf' => $uf]);
  18. return $stmt->fetchAll(\PDO::FETCH_ASSOC);
  19. }
  20. }