src/snac/server/database/SQL.php
/**
     * Update the Name Index
     *
     * Checks to see if the ICID is in the name index.  If so, it will update the values there with the parameters.  Else,
     * it will insert the new ICID and related values into the name index.
     *
     * @param string $nameEntry The name entry to include in the index
     * @param int $icid The ICID for this constellation
     * @param string $ark The ARK ID for this constellation
     * @param string $entityType The string representation of the entity type
     * @param int $degree The degree of the constellation (number of out-edges to other constellations in snac)
     * @param int $resources The number of resource relations for the constellation
     *
     * @return string[]|boolean The updated name index values or false on failure
     */
Update the Name Index
Checks to see if the ICID is in the name index.  If so, it will update the values there with the parameters.  Else,
it will insert the new ICID and related values into the name index.



@return string[]|boolean The updated name index values or false on failure
Update the Name Index Checks to see if the ICID is in the name index . If so it will update the values there with the parameters . Else it will insert the new ICID and related values into the name index . @return string [] |boolean The updated name index values or false on failure
public function updateNameIndex($nameEntry, $icid, $ark, $entityType, $degree, $resources) {
        $resultTest = $this->sdb->query("select * from name_index where ic_id = $1;", array($icid));
        $check = array();
        while($row = $this->sdb->fetchRow($resultTest))
        {
            array_push($check, $row);
        }
        if (empty($check)) {
            $result = $this->sdb->query("insert into name_index
                                            (ic_id, ark, entity_type, name_entry, name_entry_lower, degree, resources, timestamp) values
                                            ($1, $2, $3, $4, lower($4), $5, $6, now()) returning *;",
                                        array($icid, $ark, $entityType, $nameEntry, $degree, $resources));
            $all = array();
            while($row = $this->sdb->fetchRow($result))
            {
                array_push($all, $row);
            }
            return $all;
        } else {
            $result = $this->sdb->query("update name_index set
                                            (ark, entity_type, name_entry, name_entry_lower, degree, resources, timestamp) =
                                            ($2, $3, $4, lower($4), $5, $6, now()) where ic_id = $1 returning *;",
                                        array($icid, $ark, $entityType, $nameEntry, $degree, $resources));
            $all = array();
            while($row = $this->sdb->fetchRow($result))
            {
                array_push($all, $row);
            }
            return $all;
        }
        return false;
    }
public function updateNameIndex ( $ nameEntry , $ icid , $ ark , $ entityType , $ degree , $ resources ) { $ resultTest = $ this -> sdb -> query ( " select * from name_index where ic_id = $1; " , array ( $ icid ) ) ; $ check = array ( ) ; while ( $ row = $ this -> sdb -> fetchRow ( $ resultTest ) ) { array_push ( $ check , $ row ) ; } if ( empty ( $ check ) ) { $ result = $ this -> sdb -> query ( " insert into name_index
                                            (ic_id, ark, entity_type, name_entry, name_entry_lower, degree, resources, timestamp) values
                                            ($1, $2, $3, $4, lower($4), $5, $6, now()) returning *; " , array ( $ icid , $ ark , $ entityType , $ nameEntry , $ degree , $ resources ) ) ; $ all = array ( ) ; while ( $ row = $ this -> sdb -> fetchRow ( $ result ) ) { array_push ( $ all , $ row ) ; } return $ all ; } else { $ result = $ this -> sdb -> query ( " update name_index set
                                            (ark, entity_type, name_entry, name_entry_lower, degree, resources, timestamp) =
                                            ($2, $3, $4, lower($4), $5, $6, now()) where ic_id = $1 returning *; " , array ( $ icid , $ ark , $ entityType , $ nameEntry , $ degree , $ resources ) ) ; $ all = array ( ) ; while ( $ row = $ this -> sdb -> fetchRow ( $ result ) ) { array_push ( $ all , $ row ) ; } return $ all ; } return false ; }
Update the Name Index
 Checks to see if the ICID is in the name index.
Update the Name Index Checks to see if the ICID is in the name index .
// First query to see if the name is already in the index.  If so, then do an update.  Else, this is an insert. // Doing an insert, since nothing found // Doing an update, since ic_id was found