Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

SpGetImages.php 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 SpGetImages extends LuSpDbo {
  12. /**
  13. * @param $dam
  14. * @return \App\Http\DataAccess\SP\SpGetImages|null
  15. */
  16. protected static function damToDbo($dam)
  17. {
  18. if (is_null($dam))
  19. return null;
  20. $dbo = new SpGetImages();
  21. $dbo->setId(LuStringUtils::convertJsonString($dam->id));
  22. $dbo->setName(LuStringUtils::convertJsonString($dam->name));
  23. $dbo->setUserId(LuStringUtils::convertJsonString($dam->user_id));
  24. $dbo->setDate(LuStringUtils::convertJsonString($dam->date));
  25. return $dbo;
  26. }
  27. /**
  28. * @param $_only_mine boolean
  29. * @param $_user_id_me integer
  30. * @return \App\Http\DataAccess\SP\SpGetImages[];
  31. */
  32. public static function execute($_only_mine, $_user_id_me)
  33. {
  34. $values = DB::select('SELECT to_json(data.id) AS id, to_json(data.name) AS name, to_json(data.user_id) AS user_id, to_json(data.date) AS date FROM sp_get_images(:_only_mine, :_user_id_me) data', array(":_only_mine" => $_only_mine, ":_user_id_me" => $_user_id_me));
  35. $dboValues = array();
  36. foreach ($values as $value)
  37. $dboValues[] = self::damToDbo($value);
  38. return $dboValues;
  39. }
  40. /**
  41. * @param $_only_mine boolean
  42. * @param $_user_id_me integer
  43. * @param $page int The page number, 0 based
  44. * @param $perPage int The number of items per page
  45. * @return \Luticate\Utils\LuMultipleDbo;
  46. */
  47. public static function getMultipleJson($_only_mine, $_user_id_me, $page, $perPage)
  48. {
  49. $values = DB::select('SELECT (SELECT count(*) FROM sp_get_images(:_only_mine, :_user_id_me)) as count, (SELECT json_agg(q) FROM (SELECT * FROM sp_get_images(:_only_mine, :_user_id_me) OFFSET (:page::int * :perPage::int) LIMIT :perPage) q) as data',
  50. array(":_only_mine" => $_only_mine, ":_user_id_me" => $_user_id_me, ":page" => $page, ":perPage" => $perPage));
  51. $value = $values[0];
  52. if (is_null($value->data))
  53. {
  54. $value->data = '[]';
  55. }
  56. $data = LuStringUtils::convertJsonString($value->data);
  57. return new LuMultipleDbo($value->count, $data);
  58. }
  59. public function jsonSerialize()
  60. {
  61. return array(
  62. "Id" => $this->_id,
  63. "Name" => $this->_name,
  64. "UserId" => $this->_userId,
  65. "Date" => $this->_date
  66. );
  67. }
  68. public static function jsonDeserialize($json)
  69. {
  70. $dbo = new SpGetImages();
  71. if (isset($json["Id"])) {
  72. $dbo->setId($json["Id"]);
  73. }
  74. if (isset($json["Name"])) {
  75. $dbo->setName($json["Name"]);
  76. }
  77. if (isset($json["UserId"])) {
  78. $dbo->setUserId($json["UserId"]);
  79. }
  80. if (isset($json["Date"])) {
  81. $dbo->setDate($json["Date"]);
  82. }
  83. return $dbo;
  84. }
  85. public static function generateSample()
  86. {
  87. $dbo = new SpGetImages();
  88. $dbo->setId(42);
  89. $dbo->setName("sample string");
  90. $dbo->setUserId(42);
  91. $dbo->setDate("sample string");
  92. return $dbo;
  93. }
  94. /**
  95. * @var integer
  96. */
  97. protected $_id;
  98. public function getId()
  99. {
  100. return $this->_id;
  101. }
  102. public function setId($value)
  103. {
  104. $this->_id = $value;
  105. }
  106. /**
  107. * @var text
  108. */
  109. protected $_name;
  110. public function getName()
  111. {
  112. return $this->_name;
  113. }
  114. public function setName($value)
  115. {
  116. $this->_name = $value;
  117. }
  118. /**
  119. * @var integer
  120. */
  121. protected $_userId;
  122. public function getUserId()
  123. {
  124. return $this->_userId;
  125. }
  126. public function setUserId($value)
  127. {
  128. $this->_userId = $value;
  129. }
  130. /**
  131. * @var timestamp without time zone
  132. */
  133. protected $_date;
  134. public function getDate()
  135. {
  136. return $this->_date;
  137. }
  138. public function setDate($value)
  139. {
  140. $this->_date = $value;
  141. }
  142. }