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; }
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(); } }
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 j*z 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(); }
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 . ""); }