本文整理汇总了PHP中Story::getAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Story::getAttributes方法的具体用法?PHP Story::getAttributes怎么用?PHP Story::getAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Story
的用法示例。
在下文中一共展示了Story::getAttributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}