/**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aBlogCategory !== null) {
             if ($this->aBlogCategory->isModified() || $this->aBlogCategory->isNew()) {
                 $affectedRows += $this->aBlogCategory->save($con);
             }
             $this->setBlogCategory($this->aBlogCategory);
         }
         if ($this->aBlogArticle !== null) {
             if ($this->aBlogArticle->isModified() || $this->aBlogArticle->isNew()) {
                 $affectedRows += $this->aBlogArticle->save($con);
             }
             $this->setBlogArticle($this->aBlogArticle);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = BlogCategoryArticlePeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setNew(false);
             } else {
                 $affectedRows += BlogCategoryArticlePeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
 public function postProcess()
 {
     if (Tools::isSubmit('deletesmart_blog_category') && Tools::getValue('id_smart_blog_category') != '') {
         $id_lang = (int) Context::getContext()->language->id;
         $catpost = (int) SmartBlogPost::getToltalByCategory($id_lang, Tools::getValue('id_smart_blog_category'));
         if ((int) $catpost != 0) {
             $this->errors[] = Tools::displayError('You need to delete all posts associate with this category .');
         } else {
             $BlogCategory = new BlogCategory((int) Tools::getValue('id_smart_blog_category'));
             if (!$BlogCategory->delete()) {
                 $this->errors[] = Tools::displayError('An error occurred while deleting the object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>';
             } else {
                 Hook::exec('actionsbdeletecat', array('BlogCategory' => $BlogCategory));
                 Tools::redirectAdmin($this->context->link->getAdminLink('AdminBlogCategory'));
             }
         }
     } elseif (Tools::isSubmit('submitAddsmart_blog_category')) {
         parent::validateRules();
         if (count($this->errors)) {
             return false;
         }
         if (!($id_smart_blog_category = (int) Tools::getValue('id_smart_blog_category'))) {
             $BlogCategory = new BlogCategory();
             $languages = Language::getLanguages(false);
             foreach ($languages as $language) {
                 $title = str_replace('"', '', htmlspecialchars_decode(html_entity_decode(Tools::getValue('meta_title_' . $language['id_lang']))));
                 $BlogCategory->meta_title[$language['id_lang']] = $title;
                 $BlogCategory->meta_keyword[$language['id_lang']] = Tools::getValue('meta_keyword_' . $language['id_lang']);
                 $BlogCategory->meta_description[$language['id_lang']] = Tools::getValue('meta_description_' . $language['id_lang']);
                 $BlogCategory->description[$language['id_lang']] = Tools::getValue('description_' . $language['id_lang']);
                 if (Tools::getValue('link_rewrite_' . $language['id_lang']) == '' && Tools::getValue('link_rewrite_' . $language['id_lang']) == null) {
                     $BlogCategory->link_rewrite[$language['id_lang']] = str_replace(array(' ', ':', '\\', '/', '#', '!', '*', '.', '?'), '-', Tools::getValue('meta_title_' . $language['id_lang']));
                 } else {
                     $BlogCategory->link_rewrite[$language['id_lang']] = str_replace(array(' ', ':', '\\', '/', '#', '!', '*', '.', '?'), '-', Tools::getValue('link_rewrite_' . $language['id_lang']));
                 }
             }
             $BlogCategory->id_parent = Tools::getValue('id_parent');
             $BlogCategory->position = Tools::getValue('position');
             $BlogCategory->desc_limit = Tools::getValue('desc_limit');
             $BlogCategory->active = Tools::getValue('active');
             $BlogCategory->created = Date('y-m-d H:i:s');
             $BlogCategory->modified = Date('y-m-d H:i:s');
             if (!$BlogCategory->save()) {
                 $this->errors[] = Tools::displayError('An error has occurred: Can\'t save the current object');
             } else {
                 Hook::exec('actionsbnewcat', array('BlogCategory' => $BlogCategory));
                 $this->processImageCategory($_FILES, $BlogCategory->id);
                 Tools::redirectAdmin($this->context->link->getAdminLink('AdminBlogCategory'));
             }
         } elseif ($id_smart_blog_category = Tools::getValue('id_smart_blog_category')) {
             $BlogCategory = new BlogCategory($id_smart_blog_category);
             $languages = Language::getLanguages(false);
             foreach ($languages as $language) {
                 $title = str_replace('"', '', htmlspecialchars_decode(html_entity_decode(Tools::getValue('meta_title_' . $language['id_lang']))));
                 $BlogCategory->meta_title[$language['id_lang']] = $title;
                 $BlogCategory->meta_keyword[$language['id_lang']] = Tools::getValue('meta_keyword_' . $language['id_lang']);
                 $BlogCategory->meta_description[$language['id_lang']] = Tools::getValue('meta_description_' . $language['id_lang']);
                 $BlogCategory->description[$language['id_lang']] = Tools::getValue('description_' . $language['id_lang']);
                 $BlogCategory->link_rewrite[$language['id_lang']] = str_replace(array(' ', ':', '\\', '/', '#', '!', '*', '.', '?'), '-', Tools::getValue('link_rewrite_' . $language['id_lang']));
             }
             $BlogCategory->id_parent = Tools::getValue('id_parent');
             $BlogCategory->position = Tools::getValue('position');
             $BlogCategory->desc_limit = Tools::getValue('desc_limit');
             $BlogCategory->active = Tools::getValue('active');
             $BlogCategory->modified = Date('y-m-d H:i:s');
             if (!$BlogCategory->update()) {
                 $this->errors[] = Tools::displayError('An error occurred while updating an object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>';
             } else {
                 Hook::exec('actionsbupdatecat', array('BlogCategory' => $BlogCategory));
             }
             $this->processImageCategory($_FILES, $BlogCategory->id_smart_blog_category);
             Tools::redirectAdmin($this->context->link->getAdminLink('AdminBlogCategory'));
         }
     } elseif (Tools::isSubmit('statussmart_blog_category') && Tools::getValue($this->identifier)) {
         if ($this->tabAccess['edit'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject())) {
                 if ($object->toggleStatus()) {
                     Hook::exec('actionsbtogglecat', array('SmartBlogCat' => $this->object));
                     $identifier = (int) $object->id_parent ? '&id_smart_blog_category=' . (int) $object->id_parent : '';
                     Tools::redirectAdmin($this->context->link->getAdminLink('AdminBlogCategory'));
                 } else {
                     $this->errors[] = Tools::displayError('An error occurred while updating the status.');
                 }
             } else {
                 $this->errors[] = Tools::displayError('An error occurred while updating the status for an object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->errors[] = Tools::displayError('You do not have permission to edit this.');
         }
     } elseif (Tools::isSubmit('smart_blog_categoryOrderby') && Tools::isSubmit('smart_blog_categoryOrderway')) {
         $this->_defaultOrderBy = Tools::getValue('smart_blog_categoryOrderby');
         $this->_defaultOrderWay = Tools::getValue('smart_blog_categoryOrderway');
     }
 }
<?php

include 'admin-config.php';
$blogcategory_id = $blogcategory_name = $blogcategory_status = $error = "";
if (strlen(Request::post("submit"))) {
    $blogcategory_id = Request::post("blogcategory_id");
    $blogcategory_name = Request::post("blogcategory_name");
    $blogcategory_status = Validation::getStautsTinyVal(Request::post("active"));
    $blogcategoryObj = new BlogCategory();
    $blogcategoryObj->set("blogcategory_id", $blogcategory_id);
    $blogcategoryObj->set("blogcategory_name", $blogcategory_name);
    $blogcategoryObj->set("blogcategory_status", $blogcategory_status);
    if ($blogcategoryObj->save()) {
        General::redirectUrl("blog_category.php");
    } else {
        $error = "blog Category Name alreday exist !";
    }
}
include 'header.php';
include 'sitebar.php';
?>
<div class="ch-container">
    <div class="row">

        <div id="content" class="col-lg-10 col-sm-10">
            <!-- content starts -->
            <div>
                <ul class="breadcrumb">
                    <li>
                        <a href="blog_category.php">Home</a>
                    </li>