src/snac/server/database/SQL.php
/**
      * Select all names
      *
      * Constrain on version and ic_id. Code in DBUtils turns each returned list into a NameEntry
      * object. Order the returned records by preference_score descending so that preferred names are at the
      * beginning of the returned list. For ties, we also order by id, just so we'll be consistent. The
      * consistency may help testing more than UI related issues (where names should consistently appear in
      * the same order each time the record is viewed.)
      *
      * Language is a related table where language.fk_id=name.id. Contributor is a related table where
      * contributor.name_id=name.id. See selectLanguage(), selectContributor() both called in DBUtil.
      *
      * This code only knows about selecting from table name. DBUtil knows that to build a constellation it is
      * necessary to also get information related to name.
      *
      * @param string[] $vhInfo with keys version, ic_id.
      *
      * @return string[][] Return a list of lists. The inner list has keys: id, version, ic_id, original,
      * preference_score.
      */
Select all names
Constrain on version and ic_id. Code in DBUtils turns each returned list into a NameEntry
object. Order the returned records by preference_score descending so that preferred names are at the
beginning of the returned list. For ties, we also order by id, just so we'll be consistent. The
consistency may help testing more than UI related issues (where names should consistently appear in
the same order each time the record is viewed.)



This code only knows about selecting from table name. DBUtil knows that to build a constellation it is
necessary to also get information related to name.

@param string[] $vhInfo with keys version, ic_id.

@return string[][] Return a list of lists. The inner list has keys: id, version, ic_id, original,
preference_score.
Select all names Constrain on version and ic_id . Code in DBUtils turns each returned list into a NameEntry object . Order the returned records by preference_score descending so that preferred names are at the beginning of the returned list . For ties we also order by id just so we ' ll be consistent . The consistency may help testing more than UI related issues ( where names should consistently appear in the same order each time the record is viewed . ) This code only knows about selecting from table name . DBUtil knows that to build a constellation it is necessary to also get information related to name . @param string [] $vhInfo with keys version ic_id . @return string [] [] Return a list of lists . The inner list has keys : id version ic_id original preference_score .
public function selectName($vhInfo)
    {
        $qq_1 = 'selname';
        $this->sdb->prepare($qq_1,
                            'select
                            aa.is_deleted,aa.id,aa.version, aa.ic_id, aa.original, aa.preference_score
                            from name as aa,
                            (select id,max(version) as version from name where version<=$1 and ic_id=$2 group by id) as bb
                            where
                            aa.id = bb.id and not aa.is_deleted and
                            aa.version = bb.version order by preference_score desc,id asc');
        $name_result = $this->sdb->execute($qq_1,
                                           array($vhInfo['version'],
                                                 $vhInfo['ic_id']));
        $all = array();
        while($name_row = $this->sdb->fetchrow($name_result))
        {
            array_push($all, $name_row);
        }
        $this->sdb->deallocate($qq_1);
        return $all;
    }
public function selectName ( $ vhInfo ) { $ qq_1 = 'selname' ; $ this -> sdb -> prepare ( $ qq_1 , 'select
                            aa.is_deleted,aa.id,aa.version, aa.ic_id, aa.original, aa.preference_score
                            from name as aa,
                            (select id,max(version) as version from name where version<=$1 and ic_id=$2 group by id) as bb
                            where
                            aa.id = bb.id and not aa.is_deleted and
                            aa.version = bb.version order by preference_score desc,id asc' ) ; $ name_result = $ this -> sdb -> execute ( $ qq_1 , array ( $ vhInfo [ 'version' ] , $ vhInfo [ 'ic_id' ] ) ) ; $ all = array ( ) ; while ( $ name_row = $ this -> sdb -> fetchrow ( $ name_result ) ) { array_push ( $ all , $ name_row ) ; } $ this -> sdb -> deallocate ( $ qq_1 ) ; return $ all ; }
Select all names
 Constrain on version and ic_id.
Select all names Constrain on version and ic_id .
/*
             * printf("\nsn: id: %s version: %s ic_id: %s original: %s is_deleted: %s\n",
             *        $name_row['id'],
             *        $name_row['version'],
             *        $name_row['ic_id'],
             *        $name_row['original'],
             *        $name_row['is_deleted']);
             */