本文整理汇总了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;
}
示例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);
}
示例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"]);
}
示例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'));
}
示例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();
示例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');
}