当前位置: 首页>>代码示例>>PHP>>正文


PHP Article::insert方法代码示例

本文整理汇总了PHP中Article::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::insert方法的具体用法?PHP Article::insert怎么用?PHP Article::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Article的用法示例。


在下文中一共展示了Article::insert方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: newArticle

function newArticle()
{
    $results = array();
    $results['pageTitle'] = "New Article";
    $results['formAction'] = "newArticle";
    if (isset($_POST['saveChanges'])) {
        // User has posted the article edit form: save the new article
        $article = new Article();
        $article->storeFormValues($_POST);
        $article->insert();
        if (isset($_FILES['image'])) {
            $article->storeUploadedImage($_FILES['image']);
        }
        header("Location: admin.php?status=changesSaved");
    } elseif (isset($_POST['cancel'])) {
        // User has cancelled their edits: return to the article list
        header("Location: admin.php");
    } else {
        // User has not posted the article edit form yet: display the form
        $results['article'] = new Article();
        $data = Category::getList();
        $results['categories'] = $data['results'];
        require TEMPLATE_PATH . "/admin/editArticle.php";
    }
}
开发者ID:Abhijjith,项目名称:cms,代码行数:25,代码来源:admin.php

示例2: newArticle

function newArticle()
{
    $results = array();
    $results['pageTitle'] = "New Article";
    $results['formAction'] = "newArticle";
    if (isset($_POST['saveChanges'])) {
        // USer has posted the article edit form: save the new Article
        $article = new Article();
        $article->storeFormValues($_POST);
        $article->insert();
        // This checks that the 'image' element exists in the $_FILES array and, if it does exist,
        // it calls the Article object's storeUploadedImage() method, passing in the
        // $_FILES['image'] element, to store the image and create the thumbnail.
        if (isset($_FILES['image'])) {
            $article->storeUploadedImage($_FILES['image']);
        }
        header("Location: admin.php?status=changesSaved");
    } elseif (isset($_POST['cancel'])) {
        // User ha cancelled their edits: return to the article list.
        header("Location: admin.php");
    } else {
        // User has not posted the article edit form yet: display the form
        $results['article'] = new Article();
        require TEMPLATE_PATH . "/admin/editArticle.php";
    }
}
开发者ID:yun-li,项目名称:Website-PHP,代码行数:26,代码来源:admin.php

示例3: insert

 public function insert(&$data)
 {
     parent::insert($data);
     if ($this->id) {
         if (isset($data['price']) && $data['price']) {
             $this->insertItem(PRICE, preg_replace('/\\D/', '', $data['price']));
         }
         return $this->get();
     }
     return $this;
 }
开发者ID:rezaprima,项目名称:icms,代码行数:11,代码来源:store.php

示例4: insert

 public function insert(&$data, $userId = 0, $slug = '')
 {
     $poll = parent::insert($data);
     if ($poll->id) {
         foreach ($data['opt'] as $opt) {
             if ($opt) {
                 self::$dbh->query('INSERT INTO poll_opt (article_id, name) VALUES (?, ?)', array($poll->id, $opt));
             }
         }
     }
     return $poll->get();
 }
开发者ID:rezaprima,项目名称:icms,代码行数:12,代码来源:poll.php

示例5: insert

 public function insert(&$data)
 {
     parent::insert($data);
     if ($this->id) {
         if (isset($data['question']) && $data['question']) {
             $this->insertItem(QUESTION, $data['question']);
         }
         if (isset($data['alias']) && $data['alias']) {
             $this->insertItem(ALIAS, $data['alias']);
         }
         return $this->get();
     }
     return $this;
 }
开发者ID:rezaprima,项目名称:icms,代码行数:14,代码来源:consulting.php

示例6: newArticle

function newArticle()
{
    $results = array();
    $results['pageTitle'] = "New Article";
    $results['formAction'] = "newArticle";
    if (isset($_POST['saveChanges'])) {
        $article = new Article();
        $article->storeFormValues($_POST);
        $article->insert();
        header("Location: admin.php?status=changesSaved");
    } elseif (isset($_POST['cancel'])) {
        header("Location: admin.php");
    } else {
        $results['article'] = new Article();
        require TEMPLATE_PATH . "/admin/editArticle.php";
    }
}
开发者ID:DTMalfalfa,项目名称:bloggrPro,代码行数:17,代码来源:admin.php

示例7: newArticle

function newArticle()
{
    $results = array();
    $results['pageTitle'] = "New Article";
    $results['formAction'] = "newArticle";
    if (isset($_POST['saveChanges'])) {
        //user has posted the article edit form: save the new article
        $article = new Article();
        $article->storeFormValues($_POST);
        $article->insert();
        header("Location: admin.php?status=changesSaved");
    } elseif (isset($_POST['cancel'])) {
        //user has cancelled their edit: return to the article lists
        header("Location: admin.php");
    } else {
        //user has not posted the article edit form yet: display the form
        $results['article'] = new Article();
        require "templates/admin/editArticle.php";
    }
}
开发者ID:gazeis77,项目名称:hotfire_jamz,代码行数:20,代码来源:admin.php

示例8: newArticle

function newArticle()
{
    $results = array();
    $results['pageTitle'] = "New Article | The Blag";
    $results['formAction'] = "newArticle";
    /*so this is going to be interpreted down the line as a conditional to determine what exactly it is I'm doing. 
      I'll declare $results['formaction'] = "editArticle" in the editArticle() function, and then write a conditional based on these in the front-end */
    if (isset($_POST['saveChanges'])) {
        /*this isn't something to do with new articles (i.e $_POST['submit']) because I'll be using a lot of the same structure for both editArticle() and newArticle(). 
          Think about it: editing an article is just (at the end of the day) changing values in my SQL database. Creating a new article is the same thing, except rather than changing some words in a paragraph, I'm changing null values to set values. 
          It's a little different in that editArticle() uses the update() function in Article.php whereas newArticle needs to set an entirely new ID, but everything I am doing is just changing the information in the database */
        $article = new Article();
        #this takes advantage of my Articles class
        $article->storeFormValues($_POST);
        #This is the bridge from HTTP to PHP, and stores the POST in my article class.
        $article->insert();
        /* so my $article variable in a way contains all of Article.php. I can just call the variable->a function as if I were in Article.php. 
           Remember insert()? It puts the values set in Article.php (right now the POST from the user) into the database under a new ID */
        $_SESSION['id'] = $_POST['id'];
        //this is for the mail stuff
        $_SESSION['title'] = $_POST['title'];
        //same
        User::newMail();
        //same
        header("Location: admin.php?status=changesSaved");
        /* so this GET (remember, gets are in the URL in the format ~.php?key=value. ) is gonna be caught later down in the code. 
           Basically, we reload admin.php (and its switchyard) and display a little popup. Tiny bby popup. smol. */
    } elseif (isset($_POST['cancel'])) {
        #so this is gonna be determined by a "cancel changes" or some such button on the front end.
        header("Location: admin.php");
        /* since I do all of the server stuff in its own functions, as long as I don't call those functions no changes can be made to my database. 
           Since they depend on POSTs, if I just reload admin.php without POSTing anything it will work just fine to cancel changing the article */
    } else {
        #so if the user has neither canceled nor posted the article form yet
        $results['article'] = new Article();
        #declares a new Article, which doesn't sound like I need to explain it until:
        require TEMPLATE_PATH . "/admin/editArticle.php";
        /*so this will display the HTML n stuff in the (yet to be made) editArticle.php code on the page, and since I just created a new Article, it displays that one, 
          which is empty, waiting for me to do my type-y type thing */
    }
}
开发者ID:Dragonethan,项目名称:The-Blag,代码行数:41,代码来源:admin.php

示例9: newArticle

function newArticle()
{
    $results = array();
    $results['pageTitle'] = "Новая статья";
    $results['formAction'] = "newArticle";
    $results['formActionParams'] = array();
    if (isset($_POST['saveChanges'])) {
        // Пользователь заполнил форму ввода статьи: сохраняем новую статью.
        $article = new Article();
        $article->storeFormValues($_POST);
        $article->insert();
        //header("Location: index.php?action=archive&status=changesSaved");
        Notification::setStatus('changesSaved');
        Route::redirectTo('archive');
    } elseif (isset($_POST['cancel'])) {
        // Пользователь отменил правку. Возвращаемся в список статей.
        Route::redirectTo('archive');
    } else {
        // Пользователь ещё не отправил форму. Показываем форму.
        $results['article'] = new Article();
        require TEMPLATE_PATH . "/editArticle.php";
    }
}
开发者ID:Nex-Otaku,项目名称:combo-cms,代码行数:23,代码来源:index.php

示例10: Add

function Add()
{
    if (!$GLOBALS['authentication']) {
        header("Location: index.php?admin=login");
    }
    $results = array();
    $results['pageTitle'] = "Новая запись";
    $results['formAction'] = "add";
    $results['admin'] = true;
    if (isset($_POST['saveChanges'])) {
        // Пользователь получает форму редактирования статьи: сохраняем новую статью
        $article = new Article();
        $article->storeFormValues($_POST);
        $article->insert();
        //! @todo Проверка в запись БД (Добавить return)
        header("Location: index.php?new=admin&status=changesSaved");
    } elseif (isset($_POST['cancel'])) {
        // Пользователь сбросид результаты редактирования: возвращаемся к списку статей
        header("Location: index.php?new=admin");
    } else {
        // Пользователь еще не получил форму редактирования: выводим форму
        $results['article'] = new Article();
        $results['script'] = "admin/editArticle";
        require $setting["SCRIPT_PATH"] . $setting["TEMPLATE_PATH"] . "/include/page.php";
    }
}
开发者ID:winorun,项目名称:zdvlib.srv,代码行数:26,代码来源:article.php


注:本文中的Article::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。