public function findById($id) { $app = \App::getInstance(); $conn = $app->DB_CONNECT; $resource = NULL; $query = "SELECT * FROM `resources` WHERE id=? OR autoid=?;"; $sth = $conn->prepare($query); $sth->execute(array($id, $id)); while ($row = $sth->fetch()) { switch ($row['type']) { case "person": $resource = new \Archive\Port\Adaptor\Data\Archive\Persons\Person(); $resource->fromXmlStr($row["xmlview"]); break; case "union": $resource = new \Archive\Port\Adaptor\Data\Archive\Unions\Union(); $resource->fromXmlStr($row["xmlview"]); break; case "document": $resource = new \Archive\Port\Adaptor\Data\Archive\Documents\Document(); $resource->fromXmlStr($row["xmlview"]); break; default: $resource = new \Archive\Port\Adaptor\Data\Archive\Resources\Resource(); $resource->fromXmlStr($row["xmlview"]); break; } } return $resource; }
public function execute() { $app = \App::getInstance(); $unions = new \Archive\Port\Adaptor\Data\Archive\Unions(); $conn = $app->DB_CONNECT; $params = array(); $start = isset($app->QUERY['start']) ? intval($app->QUERY['start']) : 0; $count = isset($app->QUERY['count']) ? intval($app->QUERY['count']) : (isset($app->QUERY['search']) ? 100 : 100); $where = ""; if (isset($app->QUERY['type']) && $app->QUERY['type'] != "") { $where = " AND `uk`.`type` = :type"; $params[":type"] = trim($app->QUERY['type']); $ref = new \Archive\Port\Adaptor\Data\Archive\Refs\Ref(); $ref->setRel("type"); $ref->setHref(trim($app->QUERY['type'])); $unions->setRef($ref); } $query = "SELECT `r`.`xmlview` FROM `resources` AS `r` \n\t\t LEFT JOIN `unions_keys` AS `uk` ON `uk`.`unionId`=`r`.`id`\n\t\t WHERE `r`.`type`='union' {$where}\n\t\t ORDER BY `uk`.`name` LIMIT {$start},{$count};"; $sth = $conn->prepare($query); $sth->execute($params); while ($row = $sth->fetch()) { $union = new \Archive\Port\Adaptor\Data\Archive\Unions\Union(); $union->fromXmlStr($row["xmlview"]); $unions->setUnion($union); } //$unions->setPI(str_replace($app->API_VERSION.$app->PATH_INFO,"",$_SERVER["SCRIPT_URI"])."/stylesheets/Archive/Unions.xsl"); return $unions; }
public function findById($id) { $app = \App::getInstance(); $conn = $app->DB_CONNECT; $union = NULL; $params = array($id); $query = "SELECT * FROM `resources` WHERE `id`=?"; $sth = $conn->prepare($query); $sth->execute($params); while ($row = $sth->fetch()) { $union = new \Archive\Port\Adaptor\Data\Archive\Unions\Union(); $union->fromXmlStr($row["xmlview"]); } return $union; }
public function execute($id) { $app = \App::getInstance(); $unions = new \Archive\Port\Adaptor\Data\Archive\Unions(); $conn = $app->DB_CONNECT; $params = array(); $params[":id"] = $id; $ref = new \Archive\Port\Adaptor\Data\Archive\Refs\Ref(); $ref->setRel("destination"); $ref->setHref($id); $unions->setRef($ref); $query = "SELECT `r`.`xmlview` AS `rxmlview`,`l`.`xmlview` AS `lxmlview` FROM `links` AS `l` \n\t\t LEFT JOIN `resources` AS `r` ON `l`.`source`=`r`.`id`\n\t\t WHERE `l`.`destination`=:id AND `r`.`type`='union'\n\t\t ORDER BY `l`.`autoid`;"; $sth = $conn->prepare($query); $sth->execute($params); while ($row = $sth->fetch()) { $union = new \Archive\Port\Adaptor\Data\Archive\Unions\Union(); $union->fromXmlStr($row["rxmlview"]); $link = new \Archive\Port\Adaptor\Data\Archive\Links\Link(); $link->fromXmlStr($row["lxmlview"]); $union->setLink($link); $unions->setUnion($union); } return $unions; }