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


PHP Story::save方法代码示例

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


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

示例1: actionCreate

	/**
	 * Creates a new model.
	 * If creation is successful, the browser will be redirected to the 'view' page.
	 */
	public function actionCreate()
	{
		$model=new Story;

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST['Story']))
		{
			$model->attributes=$_POST['Story'];
			if($model->save())
				$this->redirect(array('view','id'=>$model->story_id));
		}

		$this->render('create',array(
			'model'=>$model,
		));
	}
开发者ID:rualatngua,项目名称:scrumopia,代码行数:22,代码来源:StoryController.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Story();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['story_title'])) {
         $model->story_title = $_POST['story_title'];
         $model->story_content = $_POST['story_content'];
         $model->product_id = $_POST['product_id'];
         //echo $id; die();
         if ($model->save()) {
             // echo var_dump($model); die();
         } else {
             die(var_dump($model->getErrors()));
         }
         //echo 'not in'; die();
         //				$this->redirect(array('view','id'=>$model->story_id));
     }
     $this->render('create', array('model' => $model, 'productId' => $model->product_id));
 }
开发者ID:indresh90,项目名称:utopeen_webpeoduct,代码行数:24,代码来源:StoryController.php

示例3: testSaveHabtmCustomKeys

 /**
  * testSaveHabtmCustomKeys method
  *
  * @return void
  */
 public function testSaveHabtmCustomKeys()
 {
     $this->loadFixtures('Story', 'StoriesTag', 'Tag');
     $Story = new Story();
     $data = array('Story' => array('story' => '1'), 'Tag' => array('Tag' => array(2, 3)));
     $result = $Story->set($data);
     $this->assertFalse(empty($result));
     $result = $Story->save();
     $this->assertFalse(empty($result));
     $result = $Story->find('all', array('order' => array('Story.story')));
     $expected = array(array('Story' => array('story' => 1, 'title' => 'First Story'), 'Tag' => array(array('id' => 2, 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31'), array('id' => 3, 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31'))), array('Story' => array('story' => 2, 'title' => 'Second Story'), 'Tag' => array()));
     $this->assertEquals($expected, $result);
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:18,代码来源:ModelWriteTest.php

示例4: array

$t->is($post->getUniqueId(), $identifier);
// @Test: getFieldsArray() generates an array with all the required fields
$keys = array_keys($post->getFieldsArray());
$t->is_deeply($keys, array('sf_unique_id', 'sf_meta_class', 'sf_meta_id', 'title_t', 'body_t'));
// @Test: getFieldsArray() generates an array with correct values
$array = $post->getFieldsArray();
$t->is($array['sf_meta_class']['value'], 'Post');
$t->is($array['sf_meta_id']['value'], $post->getId());
$t->is($array['title_t']['value'], 'title');
$t->is($array['body_t']['value'], 'body');
// @Test: deleteIndex() calls the deleteAllFromClass handler function
$handler->deleteAllFromClass('Post')->once();
$handler->commit()->once();
$handler->replay();
Doctrine::getTable('Post')->deleteIndex();
$handler->verify();
// @Test: createSearchQuery returns a Doctrine_Query object
$results = array('response' => array('docs' => array(0 => array('sf_meta_id' => 1), 3 => array('sf_meta_id' => 2), 2 => array('sf_meta_id' => 3))));
$handler->any('search')->returns($results);
$handler->replay();
$q = Doctrine::getTable('Post')->createSearchQuery('azerty');
$t->ok($q instanceof Doctrine_Query);
// @Test: I18n integration
$story = new Story();
$story->slug = 'toto';
$story->Translation['fr']->body = 'Mon histoire';
$story->Translation['en']->body = 'My story';
$story->save();
$fields = $story->getFieldsArray();
$t->ok(array_key_exists('body_fr', $fields));
$t->ok(array_key_exists('body_en', $fields));
开发者ID:heristop,项目名称:tjSolrDoctrineBehaviorPlugin,代码行数:31,代码来源:Doctrine_Template_SolrTest.php

示例5: actionCreate

 /**
  * 创建,修改故事
  */
 public function actionCreate()
 {
     ini_set('upload_max_filesize', '20M');
     ini_set('post_max_size', '20M');
     ini_set('max_input_time', 300);
     ini_set('max_execution_time', 300);
     //if(!isset($_POST)) $this->sendErrorResponse(403);
     //修改哈
     if (isset($_POST['sid'])) {
         $model = Story::model()->findByPk($_POST['sid']);
     } else {
         $model = new Story();
         //新建
         $model->share_num = $model->view_num = $model->like_num = 0;
     }
     $model->createtime = time();
     $model->uid = $_POST['uid'];
     $model->description = isset($_POST['description']) ? $_POST['description'] : '';
     $model->rec_status = isset($_POST['rec_status']) ? $_POST['rec_status'] : '';
     $model->small_img = isset($_POST['small_img']) ? $this->saveStrToImg(trim($_POST['small_img'])) : '';
     $model->story_name = $_POST['story_name'];
     if (isset($_FILES['zip_file']['tmp_name'])) {
         $target_path = "html/";
         $target_path = $target_path . $_POST['uid'] . '/' . date('YmdHi');
         $zipPath = $target_path . '/' . $_FILES['zip_file']['name'];
         if (!is_dir($target_path)) {
             $this->mkdirs($target_path);
         }
         //                $this->sendErrorResponse(404,$target_path);
         try {
             if (!move_uploaded_file($_FILES['zip_file']['tmp_name'], $zipPath)) {
                 $this->sendErrorResponse(403);
             }
             $zip = Yii::app()->zip;
             if ($zip->extractZip($zipPath, $target_path)) {
                 if (!unlink($zipPath)) {
                     $this->sendErrorResponse(500, 'del zip error');
                 }
                 $model->story_url = SITE_URL . '/' . $target_path;
             } else {
                 $this->sendErrorResponse(500, 'zip file extract error');
             }
         } catch (Exception $e) {
             $this->sendErrorResponse(403, $e->getMessage());
         }
     }
     if (!$model->save()) {
         $this->sendErrorResponse(403);
     }
     $this->sendDataResponse($model->getAttributes());
 }
开发者ID:WisapeAgency,项目名称:backend,代码行数:54,代码来源:StoryController.php


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