fork download
  1. <?php
  2.  
  3. class Collaborators
  4. {
  5. const INACTIVE = 0;
  6. const ACTIVE = 1;
  7. const ALL = 3;
  8.  
  9. public static function get(int $filter = self::ALL)
  10. {
  11. $sql = "SELECT * FROM data_collaborators";
  12.  
  13. if ($filter !== self::ALL)
  14. {
  15. $sql .= " WHERE status = " . $filter;
  16. }
  17.  
  18. //$rs = \MySQL\MySQLSelector::select_by_query_string($sql);
  19. return $sql; // Alterado para exibir a consulta SQL
  20. }
  21.  
  22. public static function actives()
  23. {
  24. return self::get(self::ACTIVE);
  25. }
  26.  
  27. public static function inactives()
  28. {
  29. return self::get(self::INACTIVE);
  30. }
  31. }
  32.  
  33. // Todos os colaboradores:
  34. echo Collaborators::get(), PHP_EOL;
  35. echo Collaborators::get(Collaborators::ALL), PHP_EOL;
  36.  
  37. // Colaboradores ativos:
  38. echo Collaborators::get(Collaborators::ACTIVE), PHP_EOL;
  39. echo Collaborators::actives(), PHP_EOL;
  40.  
  41. // Colaboradores inativos:
  42. echo Collaborators::get(Collaborators::INACTIVE), PHP_EOL;
  43. echo Collaborators::inactives(), PHP_EOL;
Success #stdin #stdout 0.03s 82880KB
stdin
Standard input is empty
stdout
SELECT * FROM data_collaborators
SELECT * FROM data_collaborators
SELECT * FROM data_collaborators WHERE status = 1
SELECT * FROM data_collaborators WHERE status = 1
SELECT * FROM data_collaborators WHERE status = 0
SELECT * FROM data_collaborators WHERE status = 0