本文整理汇总了PHP中Facilities::lastInsertId方法的典型用法代码示例。如果您正苦于以下问题:PHP Facilities::lastInsertId方法的具体用法?PHP Facilities::lastInsertId怎么用?PHP Facilities::lastInsertId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facilities
的用法示例。
在下文中一共展示了Facilities::lastInsertId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _add
private function _add()
{
use_helper('Validate');
$data = $_POST['facilities'];
Flash::set('facilities_postdata', $data);
// Add pre-save checks here
$errors = false;
// CSRF checks
if (isset($_POST['csrf_token'])) {
$csrf_token = $_POST['csrf_token'];
if (!SecureToken::validateToken($csrf_token, BASE_URL . 'facilities/add')) {
Flash::set('error', __('Invalid CSRF token found!'));
redirect(get_url('facilities/add'));
}
} else {
Flash::set('error', __('No CSRF token found!'));
redirect(get_url('facilities/add'));
}
if (empty($data['name'])) {
Flash::set('error', __('You have to specify a facilities name!'));
redirect(get_url('facilities/add'));
}
if ($errors !== false) {
// Set the errors to be displayed.
Flash::set('error', implode('<br/>', $errors));
redirect(get_url('facilities/add'));
}
$new_facilities = new Facilities($data);
$new_facilities->created_by_id = AuthUser::getId();
$new_facilities->created_on = date('Y-m-d H:i:s');
if ($new_facilities->save()) {
if (isset($_FILES)) {
if (strlen($_FILES['upload_file']['name']) > 0) {
$facilities_id = $new_facilities->lastInsertId();
$overwrite = false;
$file = $this->upload_pdf_file($facilities_id, $_FILES['upload_file']['name'], FILES_DIR . '/facilities/images/', $_FILES['upload_file']['tmp_name'], $overwrite);
if ($file === false) {
Flash::set('error', __('File has not been uploaded!'));
}
redirect(get_url('facilities/edit/' . $new_facilities->id));
}
}
Flash::set('success', __('Facilities has been added!'));
Observer::notify('facilities_after_add', $new_facilities->name);
// save and quit or save and continue editing?
if (isset($_POST['commit'])) {
redirect(get_url('facilities'));
} else {
redirect(get_url('facilities/edit/' . $new_facilities->id));
}
} else {
Flash::set('error', __('Facilities has not been added!'));
redirect(get_url('facilities/add'));
}
}