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


PHP Blog::create方法代码示例

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


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

示例1: create

 public function create($title, $body)
 {
     //モデルを呼び込む
     $blog = new Blog();
     $this->createOption = $blog->create($title, $body);
     header('Location: /seed_blog/blogs/index');
 }
开发者ID:k-nish,项目名称:seed_blog,代码行数:7,代码来源:blogs_controller.php

示例2: create

 public function create($post)
 {
     $blog = new Blog();
     $blog->create($post);
     // indexへ遷移
     header('Location: /seed_blog/blogs/index/');
 }
开发者ID:amico8,项目名称:seed_blog,代码行数:7,代码来源:blogs_controller.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     DB::table('blogs')->delete();
     Blog::create(array('id' => 1, 'title' => 'How to earn the first million', 'description' => 'Get up in the morning and go to work!', 'user_id' => 1, 'tags' => '#first million'));
     Blog::create(array('id' => 2, 'title' => 'Work on the Internet', 'description' => 'Choice is good, but you need to know a lot!', 'user_id' => 2, 'tags' => '#Work, Internet'));
     Blog::create(array('id' => 3, 'title' => 'What do you do with a daily income of 500$', 'description' => 'It remains to multiply profits and develop the company', 'user_id' => 2, 'tags' => '#company'));
     $this->command->info('Blog table seeded!');
 }
开发者ID:sergey-donchenko,项目名称:hr-agency,代码行数:14,代码来源:BlogTableSeeder.php

示例4: _new

 public function _new($blog)
 {
     if (!empty($blog)) {
         $Blog = new Blog($this->table_name, $this->action);
         $sql = $Blog->create($blog);
         mysqli_query($this->db, $sql) or die(mysqli_error($this->db));
         header("Location: index");
     }
 }
开发者ID:amico8,项目名称:seed_framework,代码行数:9,代码来源:blogs_controller.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * POST /
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $r)
 {
     $this->validate($r, ['title' => 'required', 'link' => 'required', 'content' => '']);
     $res = Blog::create(['title' => $r->get('title'), 'link' => $r->get('link'), 'content' => $r->get('content')]);
     if ($res) {
         $r->session()->flash('global', 'Запись сохранена');
         return $this->index();
     }
     return view('pages.blog.create')->withInput();
 }
开发者ID:avil13,项目名称:cross-fit.loc,代码行数:17,代码来源:GroupController.php

示例6: _new

 public function _new($blog)
 {
     // 予約語
     // プログラミング言語には、言語ごとにあらかじめ使われている変数や関数の名前があり、
     // 同じ名前を開発者が使用することができません。
     // こういった名前のことを予約語と言う。
     if (!empty($blog)) {
         $Blog = new Blog($this->plural_resource);
         $sql = $Blog->create($blog);
         mysqli_query($this->db, $sql) or die(mysqli_error($this->db));
         header("Location: index");
     }
 }
开发者ID:KoichiTakashiro,项目名称:geechscamp,代码行数:13,代码来源:blogs_controller.php

示例7: insertArticle

 public function insertArticle()
 {
     $postData = Input::all();
     $rules = array('title' => 'required', 'content' => 'required');
     $messages = array('title.required' => 'Lütfen makale başlığını girin', 'content.required' => 'Lütfen makale detaylarını girin');
     $validator = Validator::make($postData, $rules, $messages);
     if ($validator->fails()) {
         return Redirect::route('addArticle')->withInput()->withErrors($validator->messages());
     }
     $insert = Blog::create(array('user_id' => Auth::user()->id, 'title' => e($postData['title']), 'content' => e($postData['content'])));
     if (!$insert) {
         return Redirect::route('addArticle')->withInput()->withErrors(array('Makaleniz eklenirken teknik bir sorun oluştu...'));
     }
     return Redirect::route('articles');
 }
开发者ID:burak-tekin,项目名称:laravel-blog-ornegi,代码行数:15,代码来源:BlogController.php

示例8: createAction

 public function createAction()
 {
     if (!empty($_POST['submit'])) {
         $Blog = new Blog($this->_db, new User($this->_db, $_SESSION['user']['id']));
         $bind = array();
         foreach ($Blog->columns() as $key => $val) {
             if (isset($_POST[$val])) {
                 $bind[$val] = $_POST[$val];
             }
         }
         $bind['unixtime'] = time();
         if ($Blog->create($bind)) {
             $this->forward('index', array('class' => 'success', 'message' => 'Post created!'));
         } else {
             $this->_template->hud = array('class' => 'error', 'message' => 'There was an error creaging the post!');
         }
     }
 }
开发者ID:bamcod,项目名称:PubCodeHub,代码行数:18,代码来源:manageController.php

示例9: _new

 public function _new()
 {
     // まずユーザーから送られてきた情報をチェック
     if (isset($_POST['title'])) {
         if ($_POST['title'] == '') {
             $error['title'] = 'empty';
             // たぶん本当はやっちゃいけないヤツ
             $_POST['title'] = 'empty';
         }
         if ($_POST['body'] == '') {
             $error['body'] = 'empty';
             $_POST['body'] = 'empty';
         }
         if (empty($error)) {
             // 問題なければmodelを呼び出してSQL文を発行して実行する
             $Blog = new Blog($this->plural_resorce, $this->option, $this->db);
             $sql = $Blog->create();
             mysqli_query($this->db, $sql) or die(mysqli_error($this->db));
             header('Location:index');
             exit;
         }
     }
 }
开发者ID:hiroki0325,项目名称:geechscamp,代码行数:23,代码来源:blogs_contllorer.php

示例10:

<?php

require_once 'common.php';
$viewAutoLoader = (include '../../library/Nbml/sandbox_runtime.php');
echo Blog::create();
开发者ID:finalclass,项目名称:nbml,代码行数:5,代码来源:index.php

示例11:

<?php

require 'common.php';
$viewAutoLoader = (include '../../library/Nbml/sandbox_runtime.php');
echo Blog::create()->formState(true);
开发者ID:finalclass,项目名称:nbml,代码行数:5,代码来源:edit.php

示例12: Blog

<?php

$CI->load->model('Blog');
$blog = new Blog();
$blog_id = $blog->create(array("category_id" => 1, "title" => "testing"));
// $blog = new Blog($blog_id);
print_r($blog);
开发者ID:GunioRobot,项目名称:codeigniter-2-extended,代码行数:7,代码来源:run.php

示例13: dbinsert

    /**
     * Insert object into DB based on previously recorded changes
     *
     * Triggers the plugin event AfterUserInsert.
     *
     * @param boolean TRUE to automatically create new blog if group has permission
     * @return boolean true on success
     */
    function dbinsert($create_auto_blog = true)
    {
        global $Plugins, $DB;
        $DB->begin();
        if ($result = parent::dbinsert()) {
            // We could insert the user object..
            // Add new fields:
            if (!empty($this->new_fields)) {
                $sql = 'INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
								VALUES (' . $this->ID . ', ' . implode('), (' . $this->ID . ', ', $this->new_fields) . ' )';
                $DB->query($sql, 'Insert new fields');
                // Reset new fields in object:
                $this->new_fields = array();
            }
            // Notify plugins:
            // A user could be created also in another DB (to synchronize it with b2evo)
            $Plugins->trigger_event('AfterUserInsert', $params = array('User' => &$this));
            $Group =& $this->get_Group();
            if ($create_auto_blog && $Group->check_perm('perm_getblog', 'allowed')) {
                // automatically create new blog for this user
                // TODO: sam2kb> Create a blog only when this user is validated!
                $new_Blog = new Blog(NULL);
                $shortname = $this->get('login');
                $new_Blog->set('owner_user_ID', $this->ID);
                $new_Blog->set('shortname', $shortname);
                $new_Blog->set('name', $shortname . '\'s blog');
                $new_Blog->set('locale', $this->get('locale'));
                $new_Blog->set('urlname', urltitle_validate($shortname, $shortname, $new_Blog->ID, false, 'blog_urlname', 'blog_ID', 'T_blogs', $this->get('locale')));
                // Defines blog settings by its kind.
                $Plugins->trigger_event('InitCollectionKinds', array('Blog' => &$new_Blog, 'kind' => 'std'));
                $new_Blog->create();
            }
            // Save IP Range and user counter
            antispam_increase_counter('user');
        }
        $DB->commit();
        return $result;
    }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:46,代码来源:_user.class.php

示例14: Blog

     $current_User->check_perm('blogs', 'create', true);
     $edited_Blog = new Blog(NULL);
     $edited_Blog->set('owner_user_ID', $current_User->ID);
     param('kind', 'string', true);
     $edited_Blog->init_by_kind($kind);
     if (!$current_User->check_perm('blog_admin', 'edit', false, $edited_Blog->ID)) {
         // validate the urlname, which was already set by init_by_kind() function
         // It needs to validated, because the user can not set the blog urlname, and every new blog would have the same urlname without validation.
         // When user has edit permission to blog admin part, the urlname will be validated in load_from_request() function.
         $edited_Blog->set('urlname', urltitle_validate($edited_Blog->get('urlname'), '', 0, false, 'blog_urlname', 'blog_ID', 'T_blogs'));
     }
     param('skin_ID', 'integer', true);
     $edited_Blog->set_setting('normal_skin_ID', $skin_ID);
     if ($edited_Blog->load_from_Request(array())) {
         // create the new blog
         $edited_Blog->create($kind);
         // We want to highlight the edited object on next list display:
         // $Session->set( 'fadeout_array', array( 'blog_ID' => array($edited_Blog->ID) ) );
         header_redirect($dispatcher . '?ctrl=coll_settings&tab=features&blog=' . $edited_Blog->ID);
         // will save $Messages into Session
     }
     break;
 case 'delete':
     // ----------  Delete a blog from DB ----------
     // Check that this action request is not a CSRF hacked request:
     $Session->assert_received_crumb('collection');
     // Check permissions:
     $current_User->check_perm('blog_properties', 'edit', true, $blog);
     if (param('confirm', 'integer', 0)) {
         // confirmed
         // Delete from DB:
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:31,代码来源:collections.ctrl.php

示例15: dbinsert

    /**
     * Insert object into DB based on previously recorded changes
     *
     * Triggers the plugin event AfterUserInsert.
     *
     * @param boolean TRUE to automatically create new blog if group has permission
     * @return boolean true on success
     */
    function dbinsert($create_auto_blog = true)
    {
        global $Plugins, $DB;
        $DB->begin();
        if ($result = parent::dbinsert()) {
            // We could insert the user object..
            // Add new fields:
            if (!empty($this->new_fields)) {
                $sql = 'INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
								VALUES (' . $this->ID . ', ' . implode('), (' . $this->ID . ', ', $this->new_fields) . ' )';
                $DB->query($sql, 'Insert new fields');
                // Reset new fields in object:
                $this->new_fields = array();
            }
            // Notify plugins:
            // A user could be created also in another DB (to synchronize it with b2evo)
            $Plugins->trigger_event('AfterUserInsert', $params = array('User' => &$this));
            $Group =& $this->get_Group();
            if ($create_auto_blog && $Group->check_perm('perm_getblog', 'allowed')) {
                // automatically create new blog for this user
                // TODO: sam2kb> Create a blog only when this user is validated!
                $new_Blog = new Blog(NULL);
                $shortname = $this->get('login');
                $new_Blog->set('owner_user_ID', $this->ID);
                $new_Blog->set('shortname', $shortname);
                $new_Blog->set('name', $shortname . '\'s blog');
                $new_Blog->set('locale', $this->get('locale'));
                $new_Blog->set('urlname', urltitle_validate($shortname, $shortname, $new_Blog->ID, false, 'blog_urlname', 'blog_ID', 'T_blogs', $this->get('locale')));
                // Defines blog settings by its kind.
                $Plugins->trigger_event('InitCollectionKinds', array('Blog' => &$new_Blog, 'kind' => 'std'));
                $new_Blog->create();
            }
            /* Save IP Range -- start */
            $ip = int2ip(ip2int($_SERVER['REMOTE_ADDR']));
            // Convert IPv6 to IPv4
            if (preg_match('#^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$#i', $ip)) {
                // Check IP for correct format
                $ip_24bit_start = ip2int(preg_replace('#\\.\\d{1,3}$#i', '.0', $ip));
                $ip_24bit_end = ip2int(preg_replace('#\\.\\d{1,3}$#i', '.255', $ip));
                if ($iprange = get_ip_range($ip_24bit_start, $ip_24bit_end)) {
                    // Update ip range
                    $DB->query('UPDATE T_antispam__iprange
									SET aipr_user_count = ' . $DB->quote($iprange->aipr_user_count + 1) . '
									WHERE aipr_ID = ' . $DB->quote($iprange->aipr_ID));
                } else {
                    // Insert new ip range
                    $DB->query('INSERT INTO T_antispam__iprange ( aipr_IPv4start, aipr_IPv4end, aipr_user_count )
									VALUES ( ' . $DB->quote($ip_24bit_start) . ', ' . $DB->quote($ip_24bit_end) . ', ' . $DB->quote('1') . ' ) ');
                }
            }
            /* Save IP Range -- end */
        }
        $DB->commit();
        return $result;
    }
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:63,代码来源:_user.class.php


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