當前位置: 首頁>>代碼示例>>PHP>>正文


PHP dibi::getInsertId方法代碼示例

本文整理匯總了PHP中dibi::getInsertId方法的典型用法代碼示例。如果您正苦於以下問題:PHP dibi::getInsertId方法的具體用法?PHP dibi::getInsertId怎麽用?PHP dibi::getInsertId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dibi的用法示例。


在下文中一共展示了dibi::getInsertId方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _createSignature

 protected function _createSignature($type, $definition, $path)
 {
     $data = array('type' => $type, 'definition' => $definition, 'path' => $path);
     dibi::query('INSERT INTO [signatures] %v', $data);
     $signatureId = dibi::getInsertId();
     $this->_assignSignatureToMagento($signatureId);
     return $signatureId;
 }
開發者ID:djnewtown,項目名稱:judge,代碼行數:8,代碼來源:parseTags.php

示例2: addEditOnFormSubmitted

 public function addEditOnFormSubmitted(AppForm $form)
 {
     $error = false;
     dibi::begin();
     // add action
     if ($this->getAction() == 'add') {
         try {
             $values = $form->getValues();
             $roles = $values['roles'];
             unset($values['password2'], $values['roles']);
             $values['password'] = md5($values['password']);
             dibi::query('INSERT INTO [' . TABLE_USERS . '] %v;', $values);
             $user_id = dibi::getInsertId();
             if (count($roles)) {
                 foreach ($roles as $role) {
                     dibi::query('INSERT INTO [' . TABLE_USERS_ROLES . '] (user_id, role_id) VALUES (%i, %i);', $user_id, $role);
                 }
             }
             $this->flashMessage('The user has been added.', 'ok');
             dibi::commit();
             if (ACL_CACHING) {
                 unset($this->cache['gui_acl']);
                 // invalidate cache
             }
             $this->redirect('Users:');
         } catch (Exception $e) {
             $error = true;
             $form->addError('The user has not been added.');
             throw $e;
         }
     } else {
         // edit action
         $id = $this->getParam('id');
         try {
             $values = $form->getValues();
             $roles = $values['roles'];
             unset($values['roles']);
             dibi::query('UPDATE [' . TABLE_USERS . '] SET %a WHERE id=%i;', $values, $id);
             dibi::query('DELETE FROM [' . TABLE_USERS_ROLES . '] WHERE user_id=%i;', $id);
             if (count($roles)) {
                 foreach ($roles as $role) {
                     dibi::query('INSERT INTO [' . TABLE_USERS_ROLES . '] (user_id, role_id) VALUES (%i, %i);', $id, $role);
                 }
             }
             $this->flashMessage('The user has been edited.', 'ok');
             dibi::commit();
             if (ACL_CACHING) {
                 unset($this->cache['gui_acl']);
                 // invalidate cache
             }
             $this->redirect('Users:');
         } catch (Exception $e) {
             $error = true;
             $form->addError('The user has not been edited.');
             throw $e;
         }
     }
     if ($error) {
         dibi::rollback();
     }
 }
開發者ID:radypala,項目名稱:maga-website,代碼行數:61,代碼來源:UsersPresenter.php

示例3: save

 public function save()
 {
     $this->created = $this->created ? new DibiDateTime($this->created) : new DibiDateTime();
     $this->changed = $this->changed ? new DibiDateTime($this->changed) : NULL;
     // prevede data objektu na pole
     $data = get_object_vars($this);
     unset($data['simulation']);
     unset($data['force']);
     unset($data['file_prefix']);
     unset($data['file_sufix']);
     if ($data['user_id'] === '0') {
         unset($data['user_id']);
     }
     dibi::begin();
     // zkontroluje, zda jiz neni ulozen stejny soubor - podle code
     $res = dibi::query('SELECT * FROM [file] WHERE [code] = %s', $this->code);
     if ($res->getRowCount() > 0) {
         throw new DibiException("File already exists with this name. Please, try upload file with different name.", 0);
     }
     if ($this->id > 0 && !$this->force) {
         foreach ($data as $key => $value) {
             if ($value == null) {
                 unset($data[$key]);
             }
         }
         if ($this->simulation) {
             $res = dibi::test('UPDATE [file] SET', $data, 'WHERE [id]=%i', $this->id);
         } else {
             $res = dibi::query('UPDATE [file] SET', $data, 'WHERE [id]=%i', $this->id);
         }
     } else {
         if ($this->simulation) {
             $res = dibi::test('INSERT INTO file', $data);
             $this->id = 999999999;
         } else {
             if ($this->force) {
                 $res = dibi::query('INSERT IGNORE INTO file', $data);
             } else {
                 $res = dibi::query('INSERT INTO file', $data);
             }
             $this->id = dibi::getInsertId();
         }
     }
     dibi::commit();
 }
開發者ID:soundake,項目名稱:pd,代碼行數:45,代碼來源:File.php

示例4: handleCreateData

 public function handleCreateData($id, $position, $title, $type)
 {
     $position = $position + $this->numberingFrom;
     if (count($this->onCreateOwn) > 0) {
         $this->onCreateOwn($id, $position, $title, $type, $ret);
     } else {
         $data = $this->defaultValues;
         $data[$this->orderColumn] = $position;
         $data[$this->parentColumn] = (int) $id;
         $data[$this->titleColumn] = $title;
         dibi::query("INSERT INTO `{$this->table}` ", $data);
         $id = dibi::getInsertId();
         $this->onAfterCreate($id);
     }
     die($id . "");
 }
開發者ID:oaki,項目名稱:demoshop,代碼行數:16,代碼來源:JsTree.php


注:本文中的dibi::getInsertId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。