protected function insertRecord()
    {
        $sql = 'INSERT INTO '.$this->fq_name;
        $cols = '(';
        $vals = '(';
        $args = array();
        $table_def = $this->getDefinition();
        foreach($this->instance as $column => $value) {
            if (isset($this->columns[$column]['increment']) && $this->columns[$column]['increment']) {
                // omit autoincrement column from insert
                continue;
            } else if (!isset($table_def[$column])) {
                // underlying table is missing this column
                continue;
            }
            $cols .= $this->connection->identifierEscape($column).',';
            $vals .= '?,';    
            $args[] = $value;
        }
        $cols = substr($cols,0,strlen($cols)-1).')';
        $vals = substr($vals,0,strlen($vals)-1).')';
        $sql .= ' '.$cols.' VALUES '.$vals;

        $prep = $this->connection->prepare($sql);
        $result = $this->connection->execute($prep, $args);

        if ($result) {
            $this->record_changed = false;

            /** if the insert succeeded and the table contains an incrementing
                id column, that value will most likely be more useful
                than the result object */
            foreach($this->columns as $name => $info) {
                if (isset($info['increment']) && $info['increment'] === true) {
                    $new_id = $this->connection->insertID();
                    if ($new_id !== false) {
                        $result = $new_id;
                        break;
                    }
                }
            }
        }

        return $result;
    }
protected function insertRecord()
    {
        $sql = 'INSERT INTO '.$this->fq_name;
        $cols = '(';
        $vals = '(';
        $args = array();
        $table_def = $this->getDefinition();
        foreach($this->instance as $column => $value) {
            if (isset($this->columns[$column]['increment']) && $this->columns[$column]['increment']) {
                // omit autoincrement column from insert
                continue;
            } else if (!isset($table_def[$column])) {
                // underlying table is missing this column
                continue;
            }
            $cols .= $this->connection->identifierEscape($column).',';
            $vals .= '?,';    
            $args[] = $value;
        }
        $cols = substr($cols,0,strlen($cols)-1).')';
        $vals = substr($vals,0,strlen($vals)-1).')';
        $sql .= ' '.$cols.' VALUES '.$vals;

        $prep = $this->connection->prepare($sql);
        $result = $this->connection->execute($prep, $args);

        if ($result) {
            $this->record_changed = false;

            /** if the insert succeeded and the table contains an incrementing
                id column, that value will most likely be more useful
                than the result object */
            foreach($this->columns as $name => $info) {
                if (isset($info['increment']) && $info['increment'] === true) {
                    $new_id = $this->connection->insertID();
                    if ($new_id !== false) {
                        $result = $new_id;
                        break;
                    }
                }
            }
        }

        return $result;
    }
protected function insertRecord ( ) { $ sql = 'INSERT INTO ' . $ this -> fq_name ; $ cols = '(' ; $ vals = '(' ; $ args = array ( ) ; $ table_def = $ this -> getDefinition ( ) ; foreach ( $ this -> instance as $ column => $ value ) { if ( isset ( $ this -> columns [ $ column ] [ 'increment' ] ) && $ this -> columns [ $ column ] [ 'increment' ] ) { // omit autoincrement column from insert continue ; } else if ( ! isset ( $ table_def [ $ column ] ) ) { // underlying table is missing this column continue ; } $ cols .= $ this -> connection -> identifierEscape ( $ column ) . ',' ; $ vals .= '?,' ; $ args [ ] = $ value ; } $ cols = substr ( $ cols , 0 , strlen ( $ cols ) - 1 ) . ')' ; $ vals = substr ( $ vals , 0 , strlen ( $ vals ) - 1 ) . ')' ; $ sql .= ' ' . $ cols . ' VALUES ' . $ vals ; $ prep = $ this -> connection -> prepare ( $ sql ) ; $ result = $ this -> connection -> execute ( $ prep , $ args ) ; if ( $ result ) { $ this -> record_changed = false ; /** if the insert succeeded and the table contains an incrementing
                id column, that value will most likely be more useful
                than the result object */ foreach ( $ this -> columns as $ name => $ info ) { if ( isset ( $ info [ 'increment' ] ) && $ info [ 'increment' ] === true ) { $ new_id = $ this -> connection -> insertID ( ) ; if ( $ new_id !== false ) { $ result = $ new_id ; break ; } } } } return $ result ; }
Helper. Build & execute insert query
@return SQL result object or boolean false
Helper . Build & execute insert query