本文整理匯總了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;
}
示例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();
}
}
示例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();
}
示例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 . "");
}