src/db/orm/PersistableObject.php
private function doInsert(array $values) {
        $db       = $this->db();
        $mapping  = $this->dao()->getMapping();
        $table    = $mapping['table'];
        $idColumn = $mapping['identity']['column'];
        $id       = null;
        if  (isset($values[$idColumn])) $id = $values[$idColumn];
        else unset($values[$idColumn]);

        // translate column values
        foreach ($values as &$value) {
            $value = $db->escapeLiteral($value);
        }; unset($value);

        // create SQL statement
        $sql = 'insert into '.$table.' ('.join(', ', \array_keys($values)).')
                   values ('.join(', ', $values).')';

        // execute SQL statement
        if ($id) {
            $db->execute($sql);
        }
        else if ($db->supportsInsertReturn()) {
            $id = $db->query($sql.' returning '.$idColumn)->fetchInt();
        }
        else {
            $id = $db->execute($sql)->lastInsertId();
        }
        return $id;
    }
private function doInsert(array $values) {
        $db       = $this->db();
        $mapping  = $this->dao()->getMapping();
        $table    = $mapping['table'];
        $idColumn = $mapping['identity']['column'];
        $id       = null;
        if  (isset($values[$idColumn])) $id = $values[$idColumn];
        else unset($values[$idColumn]);

        // translate column values
        foreach ($values as &$value) {
            $value = $db->escapeLiteral($value);
        }; unset($value);

        // create SQL statement
        $sql = 'insert into '.$table.' ('.join(', ', \array_keys($values)).')
                   values ('.join(', ', $values).')';

        // execute SQL statement
        if ($id) {
            $db->execute($sql);
        }
        else if ($db->supportsInsertReturn()) {
            $id = $db->query($sql.' returning '.$idColumn)->fetchInt();
        }
        else {
            $id = $db->execute($sql)->lastInsertId();
        }
        return $id;
    }
private function doInsert ( array $ values ) { $ db = $ this -> db ( ) ; $ mapping = $ this -> dao ( ) -> getMapping ( ) ; $ table = $ mapping [ 'table' ] ; $ idColumn = $ mapping [ 'identity' ] [ 'column' ] ; $ id = null ; if ( isset ( $ values [ $ idColumn ] ) ) $ id = $ values [ $ idColumn ] ; else unset ( $ values [ $ idColumn ] ) ; // translate column values foreach ( $ values as & $ value ) { $ value = $ db -> escapeLiteral ( $ value ) ; } ; unset ( $ value ) ; // create SQL statement $ sql = 'insert into ' . $ table . ' (' . join ( ', ' , \ array_keys ( $ values ) ) . ')
                   values (' . join ( ', ' , $ values ) . ')' ; // execute SQL statement if ( $ id ) { $ db -> execute ( $ sql ) ; } else if ( $ db -> supportsInsertReturn ( ) ) { $ id = $ db -> query ( $ sql . ' returning ' . $ idColumn ) -> fetchInt ( ) ; } else { $ id = $ db -> execute ( $ sql ) -> lastInsertId ( ) ; } return $ id ; }
Perform the actual insertion of a data record representing the instance.

@param  array $values - record values

@return mixed - the inserted record's identity value
Perform the actual insertion of a data record representing the instance .