本文整理汇总了PHP中Catalogsys::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Catalogsys::save方法的具体用法?PHP Catalogsys::save怎么用?PHP Catalogsys::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Catalogsys
的用法示例。
在下文中一共展示了Catalogsys::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUpload
public function actionUpload()
{
parent::actionUpload();
$folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/';
// folder for uploaded files
$file = $folder . basename($_FILES['uploadfile']['name']);
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
$row = 0;
if (($handle = fopen($file, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if ($row > 0) {
$model = Catalogsys::model()->findByPk((int) $data[0]);
if ($model === null) {
$model = new Catalogsys();
}
$model->catalogsysid = (int) $data[0];
$language = Language::model()->findbyattributes(array('languagename' => $data[1]));
if ($language !== null) {
$model->languageid = $language->languageid;
}
$model->catalogname = $data[2];
$model->catalogval = $data[3];
$model->recordstatus = (int) $data[4];
try {
if (!$model->save()) {
$this->messages = $this->messages . Catalogsys::model()->getcatalog(' upload error at ' . $data[0]);
}
} catch (Exception $e) {
$this->messages = $this->messages . $e->getMessage();
}
}
$row++;
}
} else {
$this->messages = $this->messages . ' memory or harddisk full';
}
fclose($handle);
} else {
$this->messages = $this->messages . ' check your directory permission';
}
if ($this->messages == '') {
$this->messages = 'success';
}
echo $this->messages;
}