setRecords(LuStringUtils::convertJsonString($dam->records)); return $dbo; } /** * @param $domain_id integer * @param $query string * @return \App\Http\DataAccess\SP\SpGetDomainRecords[]; */ public static function execute($domain_id, $query) { $values = DB::select('SELECT to_json(data.records) AS records FROM sp_get_domain_records(:domain_id, :query) data', array(":domain_id" => $domain_id, ":query" => $query)); $dboValues = array(); foreach ($values as $value) $dboValues[] = self::damToDbo($value); return $dboValues; } /** * @param $domain_id integer * @param $query string * @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($domain_id, $query, $page, $perPage) { $values = DB::select('SELECT (SELECT count(*) FROM sp_get_domain_records(:domain_id, :query)) as count, (SELECT json_agg(q) FROM (SELECT * FROM sp_get_domain_records(:domain_id, :query) OFFSET (:page::int * :perPage::int) LIMIT :perPage) q) as data', array(":domain_id" => $domain_id, ":query" => $query, ":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( "Records" => $this->_records ); } public static function jsonDeserialize($json) { $dbo = new SpGetDomainRecords(); if (isset($json["Records"])) { $dbo->setRecords($json["Records"]); } return $dbo; } public static function generateSample() { $dbo = new SpGetDomainRecords(); $dbo->setRecords("sample string"); return $dbo; } /** * @var USER-DEFINED */ protected $_records; public function getRecords() { return $this->_records; } public function setRecords($value) { $this->_records = $value; } }