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


PHP Facilities::lastInsertId方法代码示例

本文整理汇总了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'));
     }
 }
开发者ID:sindotnet,项目名称:dashhotel,代码行数:55,代码来源:FacilitiesController.php


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