protected function insertContent(Content $content, $comment = null)
    {
        $tablename = $this->getContenttypeTablename($content->contenttype);

        // Set creation and update dates
        $content->setValue('datecreated', date('Y-m-d H:i:s'));
        $content->setValue('datechanged', date('Y-m-d H:i:s'));

        // id is set to autoincrement, so let the DB handle it
        unset($content->values['id']);

        // Get the JSON database prepared values and make sure it's valid
        $fieldvalues = $this->getValidSaveData($content->getValues(true), $content->contenttype);

        $this->app['db']->insert($tablename, $fieldvalues);

        $seq = null;
        if ($this->app['db']->getDatabasePlatform() instanceof PostgreSqlPlatform) {
            $seq = $tablename . '_id_seq';
        }

        $id = $this->app['db']->lastInsertId($seq);

        if ($id > 0) {
            $content->setValue('id', $id);
            $this->logInsert($content->contenttype['slug'], $id, $fieldvalues, $comment);

            return true;
        }
    }
protected function insertContent(Content $content, $comment = null)
    {
        $tablename = $this->getContenttypeTablename($content->contenttype);

        // Set creation and update dates
        $content->setValue('datecreated', date('Y-m-d H:i:s'));
        $content->setValue('datechanged', date('Y-m-d H:i:s'));

        // id is set to autoincrement, so let the DB handle it
        unset($content->values['id']);

        // Get the JSON database prepared values and make sure it's valid
        $fieldvalues = $this->getValidSaveData($content->getValues(true), $content->contenttype);

        $this->app['db']->insert($tablename, $fieldvalues);

        $seq = null;
        if ($this->app['db']->getDatabasePlatform() instanceof PostgreSqlPlatform) {
            $seq = $tablename . '_id_seq';
        }

        $id = $this->app['db']->lastInsertId($seq);

        if ($id > 0) {
            $content->setValue('id', $id);
            $this->logInsert($content->contenttype['slug'], $id, $fieldvalues, $comment);

            return true;
        }
    }
protected function insertContent ( Content $ content , $ comment = null ) { $ tablename = $ this -> getContenttypeTablename ( $ content -> contenttype ) ; // Set creation and update dates $ content -> setValue ( 'datecreated' , date ( 'Y-m-d H:i:s' ) ) ; $ content -> setValue ( 'datechanged' , date ( 'Y-m-d H:i:s' ) ) ; // id is set to autoincrement, so let the DB handle it unset ( $ content -> values [ 'id' ] ) ; // Get the JSON database prepared values and make sure it's valid $ fieldvalues = $ this -> getValidSaveData ( $ content -> getValues ( true ) , $ content -> contenttype ) ; $ this -> app [ 'db' ] -> insert ( $ tablename , $ fieldvalues ) ; $ seq = null ; if ( $ this -> app [ 'db' ] -> getDatabasePlatform ( ) instanceof PostgreSqlPlatform ) { $ seq = $ tablename . '_id_seq' ; } $ id = $ this -> app [ 'db' ] -> lastInsertId ( $ seq ) ; if ( $ id > 0 ) { $ content -> setValue ( 'id' , $ id ) ; $ this -> logInsert ( $ content -> contenttype [ 'slug' ] , $ id , $ fieldvalues , $ comment ) ; return true ; } }
Insert a new contenttype record in the database.

@param \Bolt\Legacy\Content $content Record content to insert
@param string               $comment Editor's comment

@return boolean
Insert a new contenttype record in the database .