src/snac/server/database/SQL.php
/**
     * Insert text records.
     *
     * Generic core function supports insert into identically structured tables. Several tables have identical
     * structure so don't copy/paste, just call this. DBUtils has code to turn the return values into objects
     * in a Constellation object.
     *
     * Solve the multi-version problem by joining to a subquery.
     *
     * @throws \snac\exceptions\SNACDatabaseException
     *
     * @param string[] $vhInfo associative list with keys: version, ic_id
     *
     * @param integer $id Record id
     *
     * @param string $text Text value we're saving
     *
     * @param string $table One of the approved tables to which this data is being written. These tables are
     * identical except for the name, so this core code saves duplication. See also selectTextCore().
     *
     * @return string[][] Return list of an associative list with keys: id, version, ic_id,
     * term_id. There may be multiple rows returned.
     *
     */
Insert text records.
Generic core function supports insert into identically structured tables. Several tables have identical
structure so don't copy/paste, just call this. DBUtils has code to turn the return values into objects
in a Constellation object.

Solve the multi-version problem by joining to a subquery.



@param string[] $vhInfo associative list with keys: version, ic_id

@param integer $id Record id

@param string $text Text value we're saving

@param string $table One of the approved tables to which this data is being written. These tables are
identical except for the name, so this core code saves duplication.

@return string[][] Return list of an associative list with keys: id, version, ic_id,
term_id. There may be multiple rows returned.
Insert text records . Generic core function supports insert into identically structured tables . Several tables have identical structure so don ' t copy / paste just call this . DBUtils has code to turn the return values into objects in a Constellation object . Solve the multi - version problem by joining to a subquery . @param string [] $vhInfo associative list with keys : version ic_id @param integer $id Record id @param string $text Text value we ' re saving @param string $table One of the approved tables to which this data is being written . These tables are identical except for the name so this core code saves duplication . @return string [] [] Return list of an associative list with keys : id version ic_id term_id . There may be multiple rows returned .
protected function insertTextCore($vhInfo, $id, $text, $table)
    {
        $approved_table = array('convention_declaration' => 1,
                                'structure_genealogy' => 1,
                                'general_context' => 1,
                                'mandate' => 1);
        if (! isset($approved_table[$table]))
        {
            throw new \snac\exceptions\SNACDatabaseException("Tried to insert on non-approved table: $table\n");
        }
        if (! $id)
        {
            $id = $this->selectID();
        }
        $qq = "select_$table";
        $this->sdb->prepare($qq,
                            sprintf(
                                'insert into %s
                                (version, ic_id, id, text)
                                values
                                ($1, $2, $3, $4)', $table));
        $result = $this->sdb->execute($qq,
                                      array($vhInfo['version'],
                                            $vhInfo['ic_id'],
                                            $id,
                                            $text));
        $this->sdb->deallocate($qq);
        return $id;
    }
protected function insertTextCore ( $ vhInfo , $ id , $ text , $ table ) { $ approved_table = array ( 'convention_declaration' => 1 , 'structure_genealogy' => 1 , 'general_context' => 1 , 'mandate' => 1 ) ; if ( ! isset ( $ approved_table [ $ table ] ) ) { throw new \ snac \ exceptions \ SNACDatabaseException ( " Tried to insert on non-approved table:  $ table \n " ) ; } if ( ! $ id ) { $ id = $ this -> selectID ( ) ; } $ qq = " select_ $ table " ; $ this -> sdb -> prepare ( $ qq , sprintf ( 'insert into %s
                                (version, ic_id, id, text)
                                values
                                ($1, $2, $3, $4)' , $ table ) ) ; $ result = $ this -> sdb -> execute ( $ qq , array ( $ vhInfo [ 'version' ] , $ vhInfo [ 'ic_id' ] , $ id , $ text ) ) ; $ this -> sdb -> deallocate ( $ qq ) ; return $ id ; }
Insert text records.
Insert text records .
/*
             * Trying something not approved is fatal.  Add an exception for this.
             */