本文整理匯總了PHP中file_storage::action_update_form方法的典型用法代碼示例。如果您正苦於以下問題:PHP file_storage::action_update_form方法的具體用法?PHP file_storage::action_update_form怎麽用?PHP file_storage::action_update_form使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類file_storage
的用法示例。
在下文中一共展示了file_storage::action_update_form方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1:
function action_update()
{
log_debug("journal_process", "Executing action_update()");
/*
Start Transaction
*/
$sql_obj = new sql_query();
$sql_obj->trans_begin();
/*
If no ID supplied, create a new journal entry first
*/
if (empty($this->structure["id"])) {
$mode = "create";
if (!$this->action_create()) {
return 0;
}
} else {
$mode = "update";
}
/*
Handle some optional fields
*/
if (!isset($this->structure["content"])) {
$this->structure["content"] = "";
}
if (!isset($this->structure["userid"])) {
// automated system user
$this->structure["userid"] = 0;
}
/*
Update journal record
*/
$sql_obj->string = "UPDATE `journal` SET " . "userid='" . $this->structure["userid"] . "', " . "customid='" . $this->structure["customid"] . "', " . "timestamp='" . $this->structure["timestamp"] . "', " . "title='" . $this->structure["title"] . "', " . "content='" . $this->structure["content"] . "' " . "WHERE id='" . $this->structure["id"] . "' LIMIT 1";
$sql_obj->execute();
/*
If journal entry is a file, upload the data
TODO: this currently only works for form uploads
*/
if ($this->structure["type"] == "file") {
if (isset($_FILES["upload"]["name"])) {
log_write("debug", "journal_process", "Uploading file against journal entry from POST form data");
// output file data
$file_obj = new file_storage();
$file_obj->data["type"] = "journal";
$file_obj->data["customid"] = $this->structure["id"];
if ($file_obj->load_data_bytype()) {
log_debug("journal_process", "Old file exists, will overwrite.");
// unset the title variable - otherwise the action_update_form function will retain the existing title
$file_obj->data["file_name"] = NULL;
} else {
log_debug("journal_process", "No previous file exists, performing clean upload.");
}
// call the upload function
if (!$file_obj->action_update_form("upload")) {
log_write("error", "journal_process", "Unable to upload file for journal entry id " . $this->structure["id"] . "");
}
} else {
// not uploading
log_write("debug", "journal_process", "No file POST data provided, not uploading file to journal - assuming manual DB upload");
}
}
/*
Commit
*/
if (error_check()) {
$sql_obj->trans_rollback();
log_write("error", "journal_process", "An error occured whilst updating the journal.");
return 0;
} else {
$sql_obj->trans_commit();
if ($this->structure["type"] != "event") {
if ($mode == "update") {
log_write("notification", "journal_process", "Journal entry updated successfully.");
} else {
log_write("notification", "journal_process", "New record added to the journal successfully.");
}
}
return 1;
}
return 0;
}
示例2: header
Update the logo file if required
*/
if ($_FILES["COMPANY_LOGO"]["size"] > 1) {
// set file variables
$file_obj->data["type"] = "COMPANY_LOGO";
$file_obj->data["customid"] = "0";
// see if a file already exists
if ($file_obj->load_data_bytype()) {
log_debug("process", "Old file exists, will overwrite.");
} else {
log_debug("process", "No previous file exists, performing clean upload.");
}
// force the filename
$file_obj->data["file_name"] = "company_logo.png";
// call the upload function
if (!$file_obj->action_update_form("COMPANY_LOGO")) {
log_write("error", "process", "Unable to upload company logo");
}
}
/*
Commit
*/
if (error_check()) {
$sql_obj->trans_rollback();
log_write("error", "process", "An error occured whilst updating configuration, no changes have been applied.");
} else {
$sql_obj->trans_commit();
log_write("notification", "process", "Company configuration updated successfully");
}
header("Location: ../index.php?page=admin/config_company.php");
exit(0);