You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * AUTO GENERATED BY LUTICATE GENERATOR
  4. * ANY CHANGES WILL BE OVERWRITTEN
  5. */
  6. namespace App\Http\DataAccess\SP;
  7. use Luticate\Utils\LuSpDbo;
  8. use Luticate\Utils\LuMultipleDbo;
  9. use Luticate\Utils\LuStringUtils;
  10. use Illuminate\Support\Facades\DB;
  11. class SpGetDomains extends LuSpDbo {
  12. /**
  13. * @param $dam
  14. * @return \App\Http\DataAccess\SP\SpGetDomains|null
  15. */
  16. protected static function damToDbo($dam)
  17. {
  18. if (is_null($dam))
  19. return null;
  20. $dbo = new SpGetDomains();
  21. $dbo->setDomains(LuStringUtils::convertJsonString($dam->domains));
  22. return $dbo;
  23. }
  24. /**
  25. * @param $query string
  26. * @return \App\Http\DataAccess\SP\SpGetDomains[];
  27. */
  28. public static function execute($query)
  29. {
  30. $values = DB::select('SELECT to_json(data.domains) AS domains FROM sp_get_domains(:query) data', array(":query" => $query));
  31. $dboValues = array();
  32. foreach ($values as $value)
  33. $dboValues[] = self::damToDbo($value);
  34. return $dboValues;
  35. }
  36. /**
  37. * @param $query string
  38. * @param $page int The page number, 0 based
  39. * @param $perPage int The number of items per page
  40. * @return \Luticate\Utils\LuMultipleDbo;
  41. */
  42. public static function getMultipleJson($query, $page, $perPage)
  43. {
  44. $values = DB::select('SELECT (SELECT count(*) FROM sp_get_domains(:query)) as count, (SELECT json_agg(q) FROM (SELECT * FROM sp_get_domains(:query) OFFSET (:page::int * :perPage::int) LIMIT :perPage) q) as data',
  45. array(":query" => $query, ":page" => $page, ":perPage" => $perPage));
  46. $value = $values[0];
  47. if (is_null($value->data))
  48. {
  49. $value->data = '[]';
  50. }
  51. $data = LuStringUtils::convertJsonString($value->data);
  52. return new LuMultipleDbo($value->count, $data);
  53. }
  54. public function jsonSerialize()
  55. {
  56. return array(
  57. "Domains" => $this->_domains
  58. );
  59. }
  60. public static function jsonDeserialize($json)
  61. {
  62. $dbo = new SpGetDomains();
  63. if (isset($json["Domains"])) {
  64. $dbo->setDomains($json["Domains"]);
  65. }
  66. return $dbo;
  67. }
  68. public static function generateSample()
  69. {
  70. $dbo = new SpGetDomains();
  71. $dbo->setDomains("sample string");
  72. return $dbo;
  73. }
  74. /**
  75. * @var USER-DEFINED
  76. */
  77. protected $_domains;
  78. public function getDomains()
  79. {
  80. return $this->_domains;
  81. }
  82. public function setDomains($value)
  83. {
  84. $this->_domains = $value;
  85. }
  86. }