src/snac/server/database/SQL.php
/**
     * Insert a version_history record.
     *
     * This always increments the version_history.version which is the version number. An old comment said: "That
     * needs to not be incremented in some cases." That is certainly not possible now. Our rule is: always
     * increment version on any database operation.
     *
     * The $mainID aka ic_id may not be minted. If we have an existing $mainID we do not create a new
     * one. This would be the case for update and delete.
     *
     * @param integer $mainID Constellation id
     *
     * @param integer $userid Foreign key to appuser.id, the current user's appuser id value.
     *
     * @param integer $role Foreign key to role.id, the role id value of the current user.
     *
     * @param string $status Status value from the enum icstatus. Using an enum from the db is a bit obscure
     * to all the php code, so maybe best to move icstatus to some util class and have a method to handle
     * these. Or a method that knows about the db class, but can hide the details from the application
     * code. Something.
     *
     * @param string $note A string the user enters to identify what changed in this version.
     * @param integer $useridSecondary optional Foreign key to appuser.id, the secondary user's appuser id value.
     *
     * @return string[] $vhInfo An assoc list with keys 'version', 'ic_id'.
     */
Insert a version_history record.
This always increments the version_history.version which is the version number. An old comment said: "That
needs to not be incremented in some cases." That is certainly not possible now. Our rule is: always
increment version on any database operation.

The $mainID aka ic_id may not be minted. If we have an existing $mainID we do not create a new
one. This would be the case for update and delete.

@param integer $mainID Constellation id

@param integer $userid Foreign key to appuser.id, the current user's appuser id value.

@param integer $role Foreign key to role.id, the role id value of the current user.

@param string $status Status value from the enum icstatus. Using an enum from the db is a bit obscure
to all the php code, so maybe best to move icstatus to some util class and have a method to handle
these. Or a method that knows about the db class, but can hide the details from the application
code. Something.

@param string $note A string the user enters to identify what changed in this version.
@param integer $useridSecondary optional Foreign key to appuser.id, the secondary user's appuser id value.

@return string[] $vhInfo An assoc list with keys 'version', 'ic_id'.
Insert a version_history record . This always increments the version_history . version which is the version number . An old comment said : " That needs to not be incremented in some cases . " That is certainly not possible now . Our rule is : always increment version on any database operation . The $mainID aka ic_id may not be minted . If we have an existing $mainID we do not create a new one . This would be the case for update and delete . @param integer $mainID Constellation id @param integer $userid Foreign key to appuser . id the current user ' s appuser id value . @param integer $role Foreign key to role . id the role id value of the current user . @param string $status Status value from the enum icstatus . Using an enum from the db is a bit obscure to all the php code so maybe best to move icstatus to some util class and have a method to handle these . Or a method that knows about the db class but can hide the details from the application code . Something . @param string $note A string the user enters to identify what changed in this version . @param integer $useridSecondary optional Foreign key to appuser . id the secondary user ' s appuser id value . @return string [] $vhInfo An assoc list with keys ' version ' ' ic_id ' .
public function insertVersionHistory($mainID, $userid, $role, $status, $note, $useridSecondary=null)
    {
        if (! $mainID)
        {
            $mainID = $this->selectID();
        }
        $qq = 'insert_version_history';
        $this->sdb->prepare($qq,
                            'insert into version_history
                            (id, user_id, role_id, status, is_current, note, user_id_secondary)
                            values
                            ($1, $2, $3, $4, $5, $6, $7)
                            returning version');
        $result = $this->sdb->execute($qq, array($mainID, $userid, $role, $status, true, $note, $useridSecondary));
        $row = $this->sdb->fetchrow($result);
        $vhInfo['version'] = $row['version'];
        $vhInfo['ic_id'] = $mainID;
        $this->sdb->deallocate($qq);
        return $vhInfo;
    }
public function insertVersionHistory ( $ mainID , $ userid , $ role , $ status , $ note , $ useridSecondary = null ) { if ( ! $ mainID ) { $ mainID = $ this -> selectID ( ) ; } $ qq = 'insert_version_history' ; $ this -> sdb -> prepare ( $ qq , 'insert into version_history
                            (id, user_id, role_id, status, is_current, note, user_id_secondary)
                            values
                            ($1, $2, $3, $4, $5, $6, $7)
                            returning version' ) ; $ result = $ this -> sdb -> execute ( $ qq , array ( $ mainID , $ userid , $ role , $ status , true , $ note , $ useridSecondary ) ) ; $ row = $ this -> sdb -> fetchrow ( $ result ) ; $ vhInfo [ 'version' ] = $ row [ 'version' ] ; $ vhInfo [ 'ic_id' ] = $ mainID ; $ this -> sdb -> deallocate ( $ qq ) ; return $ vhInfo ; }
Insert a version_history record.
Insert a version_history record .
// We need version_history.id and version_history.id returned.