setId(LuStringUtils::convertJsonString($dam->id)); $dbo->setName(LuStringUtils::convertJsonString($dam->name)); $dbo->setUserId(LuStringUtils::convertJsonString($dam->user_id)); $dbo->setDate(LuStringUtils::convertJsonString($dam->date)); return $dbo; } /** * @param $_only_mine boolean * @param $_user_id_me integer * @return \App\Http\DataAccess\SP\SpGetImages[]; */ public static function execute($_only_mine, $_user_id_me) { $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)); $dboValues = array(); foreach ($values as $value) $dboValues[] = self::damToDbo($value); return $dboValues; } /** * @param $_only_mine boolean * @param $_user_id_me integer * @param $page int The page number, 0 based * @param $perPage int The number of items per page * @return \Luticate\Utils\LuMultipleDbo; */ public static function getMultipleJson($_only_mine, $_user_id_me, $page, $perPage) { $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', array(":_only_mine" => $_only_mine, ":_user_id_me" => $_user_id_me, ":page" => $page, ":perPage" => $perPage)); $value = $values[0]; if (is_null($value->data)) { $value->data = '[]'; } $data = LuStringUtils::convertJsonString($value->data); return new LuMultipleDbo($value->count, $data); } public function jsonSerialize() { return array( "Id" => $this->_id, "Name" => $this->_name, "UserId" => $this->_userId, "Date" => $this->_date ); } public static function jsonDeserialize($json) { $dbo = new SpGetImages(); if (isset($json["Id"])) { $dbo->setId($json["Id"]); } if (isset($json["Name"])) { $dbo->setName($json["Name"]); } if (isset($json["UserId"])) { $dbo->setUserId($json["UserId"]); } if (isset($json["Date"])) { $dbo->setDate($json["Date"]); } return $dbo; } public static function generateSample() { $dbo = new SpGetImages(); $dbo->setId(42); $dbo->setName("sample string"); $dbo->setUserId(42); $dbo->setDate("sample string"); return $dbo; } /** * @var integer */ protected $_id; public function getId() { return $this->_id; } public function setId($value) { $this->_id = $value; } /** * @var text */ protected $_name; public function getName() { return $this->_name; } public function setName($value) { $this->_name = $value; } /** * @var integer */ protected $_userId; public function getUserId() { return $this->_userId; } public function setUserId($value) { $this->_userId = $value; } /** * @var timestamp without time zone */ protected $_date; public function getDate() { return $this->_date; } public function setDate($value) { $this->_date = $value; } }