src/snac/server/database/SQL.php
/**
     * Return the lowest ic_id
     *
     * Return the lowest ic_id for a multi-name constellation with 2 or more non-deleted names. Returns a
     * version and ic_id for the constelletion to which this name belongs.
     *
     * This is a helper/convenience function for testing purposes only.
     *
     * Note: When getting a version number, we must always look for max(version_history.version) as version to be
     * sure we have "the" constellation version number.
     *
     * Subquery zz returns count of names that are not deleted, grouped by ic_id (akd main_id, aka
     * constellation id). Join that to version history, and constrain for zz.count>1 and you have multi-name
     * constellations, then limit to 1 result.
     *
     * @return integer[] Returns a vhInfo associateve list of integers with key names 'version' and
     * 'ic_id'. The ic_id is from table 'name' for the multi-alt string name. That ic_id is a
     * constellation id, so we call selectCurrentVersion() to get the current version for that
     * constellation. This allows us to return a conventional vhInfo associative list which is conventient
     * return value. (Convenient, in that we do extra work so the calling code is simpler.)
     */
Return the lowest ic_id
Return the lowest ic_id for a multi-name constellation with 2 or more non-deleted names. Returns a
version and ic_id for the constelletion to which this name belongs.

This is a helper/convenience function for testing purposes only.

When getting a version number, we must always look for max(version_history.version) as version to be
sure we have "the" constellation version number.

Subquery zz returns count of names that are not deleted, grouped by ic_id (akd main_id, aka
constellation id). Join that to version history, and constrain for zz.count>1 and you have multi-name
constellations, then limit to 1 result.

@return integer[] Returns a vhInfo associateve list of integers with key names 'version' and
'ic_id'. The ic_id is from table 'name' for the multi-alt string name. That ic_id is a
constellation id, so we call selectCurrentVersion() to get the current version for that
constellation. This allows us to return a conventional vhInfo associative list which is conventient
return value. (Convenient, in that we do extra work so the calling code is simpler.)
Return the lowest ic_id Return the lowest ic_id for a multi - name constellation with 2 or more non - deleted names . Returns a version and ic_id for the constelletion to which this name belongs . This is a helper / convenience function for testing purposes only . When getting a version number we must always look for max ( version_history . version ) as version to be sure we have " the " constellation version number . Subquery zz returns count of names that are not deleted grouped by ic_id ( akd main_id aka constellation id ) . Join that to version history and constrain for zz . count > 1 and you have multi - name constellations then limit to 1 result . @return integer [] Returns a vhInfo associateve list of integers with key names ' version ' and ' ic_id ' . The ic_id is from table ' name ' for the multi - alt string name . That ic_id is a constellation id so we call selectCurrentVersion () to get the current version for that constellation . This allows us to return a conventional vhInfo associative list which is conventient return value . ( Convenient in that we do extra work so the calling code is simpler . )
public function sqlMultiNameConstellationID()
    {
        $qq = 'mncid';
        $this->sdb->prepare($qq,
                            'select max(vh.version) as version, vh.id as ic_id
                            from version_history as vh,
                            (select count(distinct(aa.id)),aa.ic_id from name as aa
                            where aa.id not in (select id from name where is_deleted) group by ic_id order by ic_id) as zz
                            where
                            vh.id=zz.ic_id and
                            vh.status <> $1 and
                            zz.count>1 group by vh.id limit 1');
        $result = $this->sdb->execute($qq, array($this->deleted));
        $row = $this->sdb->fetchrow($result);
        $version = $this->selectCurrentVersion($row['ic_id']);
        $this->sdb->deallocate($qq);
        return array('version' => $version,
                     'ic_id' => $row['ic_id']);
    }
public function sqlMultiNameConstellationID ( ) { $ qq = 'mncid' ; $ this -> sdb -> prepare ( $ qq , 'select max(vh.version) as version, vh.id as ic_id
                            from version_history as vh,
                            (select count(distinct(aa.id)),aa.ic_id from name as aa
                            where aa.id not in (select id from name where is_deleted) group by ic_id order by ic_id) as zz
                            where
                            vh.id=zz.ic_id and
                            vh.status <> $1 and
                            zz.count>1 group by vh.id limit 1' ) ; $ result = $ this -> sdb -> execute ( $ qq , array ( $ this -> deleted ) ) ; $ row = $ this -> sdb -> fetchrow ( $ result ) ; $ version = $ this -> selectCurrentVersion ( $ row [ 'ic_id' ] ) ; $ this -> sdb -> deallocate ( $ qq ) ; return array ( 'version' => $ version , 'ic_id' => $ row [ 'ic_id' ] ) ; }
Return the lowest ic_id
 Return the lowest ic_id for a multi-name constellation with 2 or more non-deleted names.
Return the lowest ic_id Return the lowest ic_id for a multi - name constellation with 2 or more non - deleted names .