src/snac/server/database/DBUtil.php
/**
     * Save place object
     *
     * Save a list of places to place_link, including meta data.
     *
     * The only way to know the related table is for it to be passed in via $relatedTable.
     *
     * @param integer[] $vhInfo Array with keys 'version', 'ic_id' for this constellation.
     *
     * @param \snac\data\AbstractData Object $id An object that might have a place, and that extends
     * AbstractData.
     *
     * @param string $relatedTable Name of the related table for this place.
     * @param integer $fkID Foreign key row id aka table.id from the related table.
     *
     */
Save place object
Save a list of places to place_link, including meta data.

The only way to know the related table is for it to be passed in via $relatedTable.

@param integer[] $vhInfo Array with keys 'version', 'ic_id' for this constellation.

@param \snac\data\AbstractData Object $id An object that might have a place, and that extends
AbstractData.

@param string $relatedTable Name of the related table for this place.
@param integer $fkID Foreign key row id aka table.id from the related table.
Save place object Save a list of places to place_link including meta data . The only way to know the related table is for it to be passed in via $relatedTable . @param integer [] $vhInfo Array with keys ' version ' ' ic_id ' for this constellation . @param \ snac \ data \ AbstractData Object $id An object that might have a place and that extends AbstractData . @param string $relatedTable Name of the related table for this place . @param integer $fkID Foreign key row id aka table . id from the related table .
private function savePlace($vhInfo, $cObj, $relatedTable, $fkID)
    {
        if ($placeList = $cObj->getPlaces())
        {
            foreach($placeList as $gObj)
            {
                $pid = $gObj->getID();
                if ($this->prepOperation($vhInfo, $gObj))
                {
                    $pid = $this->sql->insertPlace($vhInfo,
                                                   $gObj->getID(),
                                                   $this->db->boolToPg($gObj->getConfirmed()),
                                                   $gObj->getOriginal(),
                                                   $this->thingID($gObj->getGeoTerm()),
                                                   $this->termID($gObj->getType()),
                                                   $this->termID($gObj->getRole()),
                                                   $gObj->getNote(),
                                                   $gObj->getScore(),
                                                   $relatedTable,
                                                   $fkID);
                    $gObj->setID($pid);
                    $gObj->setVersion($vhInfo['version']);
                }
                $this->saveMeta($vhInfo, $gObj, 'place_link', $pid);
                if ($dObj = $gObj->getDateList())
                {
                    if (is_array($dObj))
                    {
                        foreach ($dObj as $date)
                        {
                            $this->saveDate($vhInfo, $date, 'place_link', $pid);
                        }
                    }
                }
                if ($addressList = $gObj->getAddress())
                {
                    foreach($addressList as $addr)
                    {
                        if ($this->prepOperation($vhInfo, $addr))
                        {
                            $rid = $this->sql->insertAddressLine($vhInfo,
                                                               $addr->getID(),
                                                               $pid,
                                                               $addr->getText(),
                                                               $this->termID($addr->getType()),
                                                               $addr->getOrder());
                            $addr->setID($rid);
                            $addr->setVersion($vhInfo['version']);
                        }
                    }
                }
            }
        }
    }
private function savePlace ( $ vhInfo , $ cObj , $ relatedTable , $ fkID ) { if ( $ placeList = $ cObj -> getPlaces ( ) ) { foreach ( $ placeList as $ gObj ) { $ pid = $ gObj -> getID ( ) ; if ( $ this -> prepOperation ( $ vhInfo , $ gObj ) ) { $ pid = $ this -> sql -> insertPlace ( $ vhInfo , $ gObj -> getID ( ) , $ this -> db -> boolToPg ( $ gObj -> getConfirmed ( ) ) , $ gObj -> getOriginal ( ) , $ this -> thingID ( $ gObj -> getGeoTerm ( ) ) , $ this -> termID ( $ gObj -> getType ( ) ) , $ this -> termID ( $ gObj -> getRole ( ) ) , $ gObj -> getNote ( ) , $ gObj -> getScore ( ) , $ relatedTable , $ fkID ) ; $ gObj -> setID ( $ pid ) ; $ gObj -> setVersion ( $ vhInfo [ 'version' ] ) ; } $ this -> saveMeta ( $ vhInfo , $ gObj , 'place_link' , $ pid ) ; if ( $ dObj = $ gObj -> getDateList ( ) ) { if ( is_array ( $ dObj ) ) { foreach ( $ dObj as $ date ) { $ this -> saveDate ( $ vhInfo , $ date , 'place_link' , $ pid ) ; } } } if ( $ addressList = $ gObj -> getAddress ( ) ) { foreach ( $ addressList as $ addr ) { if ( $ this -> prepOperation ( $ vhInfo , $ addr ) ) { $ rid = $ this -> sql -> insertAddressLine ( $ vhInfo , $ addr -> getID ( ) , $ pid , $ addr -> getText ( ) , $ this -> termID ( $ addr -> getType ( ) ) , $ addr -> getOrder ( ) ) ; $ addr -> setID ( $ rid ) ; $ addr -> setVersion ( $ vhInfo [ 'version' ] ) ; } } } } } }
Save place object
 Save a list of places to place_link, including meta data.
Save place object Save a list of places to place_link including meta data .
/*
                     * The docs for getDateList() imply that in some circumstances it does not return a list,
                     * not even an empty list. We have to check.
                     */ /*
                 * Inline the code that would be saveAddress() because it is only used here.
                 */