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


PHP Content::create方法代码示例

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


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

示例1: saveContent

 /**
  * コンテンツデータを登録する
  * コンテンツデータを次のように作成して引き渡す
  * array('Content' =>
  * 			array(	'model_id'	=> 'モデルでのID'
  * 					'category'	=> 'カテゴリ名',
  * 					'title'		=> 'コンテンツタイトル',		// 検索対象
  * 					'detail'	=> 'コンテンツ内容',		// 検索対象
  * 					'url'		=> 'URL',
  * 					'status' => '公開ステータス'
  * ))
  *
  * @param Model $model
  * @param array $data
  * @return boolean
  * @access public
  */
 public function saveContent(Model $model, $data)
 {
     if (!$data) {
         return;
     }
     $data['Content']['model'] = $model->alias;
     // タグ、空白を除外
     $data['Content']['detail'] = str_replace(array("\r\n", "\r", "\n", "\t", "\\s"), '', trim(strip_tags($data['Content']['detail'])));
     // 検索用データとして保存
     $id = '';
     $this->Content = ClassRegistry::init('Content');
     if (!empty($data['Content']['model_id'])) {
         $before = $this->Content->find('first', array('fields' => array('Content.id', 'Content.category'), 'conditions' => array('Content.model' => $data['Content']['model'], 'Content.model_id' => $data['Content']['model_id'])));
     }
     if ($before) {
         $data['Content']['id'] = $before['Content']['id'];
         $this->Content->set($data);
     } else {
         if (empty($data['Content']['priority'])) {
             $data['Content']['priority'] = '0.5';
         }
         $this->Content->create($data);
     }
     $result = $this->Content->save();
     // カテゴリを site_configsに保存
     if ($result) {
         return $this->updateContentMeta($model, $data['Content']['category']);
     }
     return $result;
 }
开发者ID:naow9y,项目名称:basercms,代码行数:47,代码来源:BcContentsManagerBehavior.php

示例2: create

 public function create($user_id, $post = array())
 {
     if (!isset($post['id']) || $post['id'] != $this->user_id) {
         $post['id'] = $user_id;
     }
     parent::create($user_id, $post);
 }
开发者ID:k-kalashnikov,项目名称:forKoda,代码行数:7,代码来源:userprofile.php

示例3: create

 public function create()
 {
     $content = new Content();
     $company = $this->user->getCompany() ? "(" . $this->user->getCompany() . ")" : " ";
     $_POST["description"] .= " -- " . $this->user->getUsername() . $company;
     $result = $content->create();
     header("Location: " . $_GET["id"]);
 }
开发者ID:asancheza,项目名称:box,代码行数:8,代码来源:ContentController.php

示例4: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('content')->delete();
     Content::create(array('body' => 'first sentence', 'type' => 'homepage'));
     Content::create(array('body' => 'second sentence', 'type' => 'homepage'));
     Content::create(array('body' => 'third sentence', 'type' => 'homepage'));
     Content::create(array('body' => 'forth sentence', 'type' => 'homepage'));
 }
开发者ID:TheCompleteCode,项目名称:laravel-kdc,代码行数:13,代码来源:ContentTableSeeder.php

示例5:

<?php

/**
 * Created by PhpStorm.
 * User: munabste
 * Date: 8/24/2015
 * Time: 10:31 AM
 */
require_once 'php-activerecord/ActiveRecord.php';
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory('models');
    $cfg->set_connections(array('development' => 'mysql://root:@localhost/xapp_base'));
});
# create Tito
$content = Content::create(array('name' => 'about', 'discription' => 'this page describes the about info', 'content' => 'This is the content for this page'));
# read Tito
//$user = User::find_by_id('2');
# update Tito
//$user->name = 'Tito Jr';
//$user->save();
# delete Tito
//$user->delete();
开发者ID:stephenx99,项目名称:design-pattens,代码行数:22,代码来源:index.php

示例6: storeContent

 public function storeContent()
 {
     $v = Validator::make(Input::all(), ['title' => 'required|min:5', 'content' => 'required|min:10']);
     if ($v->fails()) {
         return Redirect::back()->withErrors($v->messages())->withInput();
     }
     $content = Content::create(Input::all());
     if ($content->save()) {
         return Redirect::back()->with('flash_message', 'Content successfully created');
     }
     return Redirect::back()->withErrors('An error occured. Please contact server administrator');
 }
开发者ID:jmramos02,项目名称:catering,代码行数:12,代码来源:AdminController.php


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