src/snac/server/database/SQL.php
/**
     * Count names, current version, not deleted, for a single constellation.
     *
     * This is used to check if we are allowed to delete a name, because we must not delete the only name for
     * a constellation.
     *
     * Note that Postgres names the column from the count() function 'count', so we do not need to alias the
     * column. I used the explicit alias just to make intent clear.
     *
     * @param $mainID Integer constellation id usually from version_history.id.
     *
     * @return interger Number of names meeting the criteria. Zero if no names or if the query fails.
     *
     */
Count names, current version, not deleted, for a single constellation.
This is used to check if we are allowed to delete a name, because we must not delete the only name for
a constellation.

Note that Postgres names the column from the count() function 'count', so we do not need to alias the
column. I used the explicit alias just to make intent clear.

@param $mainID Integer constellation id usually from version_history.id.

@return interger Number of names meeting the criteria. Zero if no names or if the query fails.
Count names current version not deleted for a single constellation . This is used to check if we are allowed to delete a name because we must not delete the only name for a constellation . Note that Postgres names the column from the count () function ' count ' so we do not need to alias the column . I used the explicit alias just to make intent clear . @param $mainID Integer constellation id usually from version_history . id . @return interger Number of names meeting the criteria . Zero if no names or if the query fails .
public function parentCountNames($mainID)
    {
        $selectSQL =
            "select count(*) as count from name as aa,
            (select id, ic_id, max(version) as version from name group by id,ic_id) as bb
            where aa.id=bb.id and not aa.is_deleted and aa.version=bb.version and aa.ic_id=bb.ic_id and aa.ic_id=$1";
        $result = $this->sdb->query($selectSQL, array($mainID));
        $row = $this->sdb->fetchrow($result);
        if ($row and isset($row['count']))
        {
            return $row['count'];
        }
        else
        {
            return 0;
        }
    }
public function parentCountNames ( $ mainID ) { $ selectSQL = " select count(*) as count from name as aa,
            (select id, ic_id, max(version) as version from name group by id,ic_id) as bb
            where aa.id=bb.id and not aa.is_deleted and aa.version=bb.version and aa.ic_id=bb.ic_id and aa.ic_id=$1 " ; $ result = $ this -> sdb -> query ( $ selectSQL , array ( $ mainID ) ) ; $ row = $ this -> sdb -> fetchrow ( $ result ) ; if ( $ row and isset ( $ row [ 'count' ] ) ) { return $ row [ 'count' ] ; } else { return 0 ; } }
Count names, current version, not deleted, for a single constellation.
Count names current version not deleted for a single constellation .