src/snac/server/database/SQL.php
/**
     * Select Holdings
     *
     * Selects all resource holdings of a holding repository.
     * Query searches for resources with the desired repo_ic_ids, first checking for merged repo_ic_ids,
     * then finding max version of those resource and finally pulling full resources and filtering them.
     *
     * @param integer $icid The id of the holding repository
     * @return string[] Returns associative array of resources data
     */
Select Holdings
Selects all resource holdings of a holding repository.
Query searches for resources with the desired repo_ic_ids, first checking for merged repo_ic_ids,
then finding max version of those resource and finally pulling full resources and filtering them.

@param integer $icid The id of the holding repository
@return string[] Returns associative array of resources data
Select Holdings Selects all resource holdings of a holding repository . Query searches for resources with the desired repo_ic_ids first checking for merged repo_ic_ids then finding max version of those resource and finally pulling full resources and filtering them . @param integer $icid The id of the holding repository @return string [] Returns associative array of resources data
public function selectHoldings($icid) {
        $query = "WITH holding_repo_ids AS ( SELECT ic_id FROM constellation_lookup WHERE current_ic_id = $1 )
                  SELECT r1.id AS \"RD-Source-ID\", r1.version, r1.href AS \"RD-URL\", v.value AS \"RD-Type\",
                      r1.title, r1.abstract, r1.extent, r1.date, $1 AS repository_id, r1.updated_at
                  FROM resource_cache r1
                      LEFT JOIN vocabulary v ON r1.type = v.id
                      INNER JOIN
                          (SELECT id, max(version) AS version
                              FROM resource_cache
                              WHERE id IN
                              ( SELECT id FROM resource_cache
                                  WHERE repo_ic_id IN (select ic_id from holding_repo_ids)
                              )
                              GROUP BY id
                          ) AS r2
                      ON r1.id = r2.id
                      AND r1.version = r2.version
                  WHERE r1.repo_ic_id in (select ic_id from holding_repo_ids)
                      AND NOT r1.is_deleted;";
        $result = $this->sdb->query($query, array($icid));
        return $this->sdb->fetchAll($result);
    }
public function selectHoldings ( $ icid ) { $ query = " WITH holding_repo_ids AS ( SELECT ic_id FROM constellation_lookup WHERE current_ic_id = $1 )
                  SELECT r1.id AS  \" RD-Source-ID \" , r1.version, r1.href AS  \" RD-URL \" , v.value AS  \" RD-Type \" ,
                      r1.title, r1.abstract, r1.extent, r1.date, $1 AS repository_id, r1.updated_at
                  FROM resource_cache r1
                      LEFT JOIN vocabulary v ON r1.type = v.id
                      INNER JOIN
                          (SELECT id, max(version) AS version
                              FROM resource_cache
                              WHERE id IN
                              ( SELECT id FROM resource_cache
                                  WHERE repo_ic_id IN (select ic_id from holding_repo_ids)
                              )
                              GROUP BY id
                          ) AS r2
                      ON r1.id = r2.id
                      AND r1.version = r2.version
                  WHERE r1.repo_ic_id in (select ic_id from holding_repo_ids)
                      AND NOT r1.is_deleted; " ; $ result = $ this -> sdb -> query ( $ query , array ( $ icid ) ) ; return $ this -> sdb -> fetchAll ( $ result ) ; }
Select Holdings
 Selects all resource holdings of a holding repository.
Select Holdings Selects all resource holdings of a holding repository .