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


PHP dibi::commit方法代码示例

本文整理汇总了PHP中dibi::commit方法的典型用法代码示例。如果您正苦于以下问题:PHP dibi::commit方法的具体用法?PHP dibi::commit怎么用?PHP dibi::commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dibi的用法示例。


在下文中一共展示了dibi::commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteMd

/**
 * Metainformation catalogue
 * --------------------------------------------------
 *
 * MICKA_LIB_INSERT.PHP for MicKa
 *
 * @link       http://www.bnhelp.cz
 * @package    Micka
 * @category   Metadata
 * @version    20101120
 * @authors		 DZ
 */
function deleteMd($user, $type, $value, $mode, $par = NULL)
{
    setMickaLog('micka_lib_insert.php (deleteMd)', 'DEBUG', "user={$user}, {$type}={$value}, mode={$mode}, par={$par}");
    $rs = FALSE;
    // autorizace
    if ($user == 'guest' || !canAction()) {
        return $rs;
    }
    $record = getMdHeader($type, $value, $col = '', $fetch = array('all', '='));
    if (isset($record[0]['RECNO']) && $record[0]['RECNO'] > -1) {
        if (!getMdRight('edit', $user, $record[0]['DATA_TYPE'], $record[0]['CREATE_USER'], $record[0]['EDIT_GROUP'], $record[0]['VIEW_GROUP'])) {
            return $rs;
        } else {
            $sql = array();
            if ($mode == 'all') {
                array_push($sql, 'DELETE FROM [md_values] WHERE [recno]=%i;', $record[0]['RECNO']);
                array_push($sql, 'DELETE FROM [md] WHERE [recno]=%i;', $record[0]['RECNO']);
            } elseif ($mode == 'value') {
                array_push($sql, 'DELETE FROM [md_values] WHERE [recno]=%i  AND md_id<>38;', $record[0]['RECNO']);
            }
            dibi::begin();
            try {
                dibi::query($sql);
                dibi::commit();
                $rs = TRUE;
            } catch (DibiException $e) {
                setMickaLog($e, 'ERROR', 'micka_lib_insert.php (deleteMd)');
                dibi::rollback();
            }
        }
    }
    //Debug::dump($rs);
    setMickaLog('micka_lib_insert.php (deleteMd)', 'DEBUG', "return={$rs}");
    return $rs;
}
开发者ID:riskatlas,项目名称:micka,代码行数:47,代码来源:micka_lib_insert.php

示例2: createOrder

 static function createOrder($values, $id_product_params, $id_lang, $user)
 {
     dibi::begin();
     //		print_r($values);exit;
     dibi::query("INSERT INTO [order]", $values);
     $order_id = dibi::insertId();
     foreach ($id_product_params as $id_product_param => $count) {
         self::insertProduct($id_product_param, $count, $order_id, $id_lang, $user);
     }
     dibi::commit();
     return $order_id;
 }
开发者ID:oaki,项目名称:demoshop,代码行数:12,代码来源:OrderModel.php

示例3: render

 public function render($args = NULL)
 {
     parent::render($args);
     $this->template->database = $this->context->database;
     $this->template->subjects = $this->subjects->fetchAd($this->strict);
     $this->template->type = $this->type;
     $this->template->setFile(__DIR__ . "/BannerSubjects.latte");
     dibi::begin();
     foreach ($this->subjects as $key => $value) {
         dibi::query('update subject set ad_show_count=ad_show_count+1 where id=' . $key);
     }
     dibi::commit();
     $this->template->render();
 }
开发者ID:soundake,项目名称:pd,代码行数:14,代码来源:BannerSubjects.php

示例4: updateUserRoles

 /**
  * update user roles [delete & insert]
  *
  * @param int User id
  * @param int Role id
  */
 public function updateUserRoles($userId, $roles)
 {
     try {
         dibi::begin();
         dibi::delete(self::ACL_USERS_2_ROLES_TABLE)->where('user_id = %i', $userId)->execute();
         foreach ($roles as $role) {
             dibi::insert(self::ACL_USERS_2_ROLES_TABLE, array('user_id' => $userId, 'role_id' => $role))->execute();
         }
         dibi::commit();
     } catch (DibiDriverException $e) {
         dibi::rollback();
         throw $e;
     }
 }
开发者ID:radypala,项目名称:maga-website,代码行数:20,代码来源:RolesModel.php

示例5: save

 /**
  * Save given order
  * @param order
  * @param array
  * @return bool
  */
 public function save(order $order, array $products, array $visited)
 {
     // order data
     $data = $order->__toArray();
     $data['at'] = date('Y-m-d H:i:s', time());
     $data['delivery_type_id'] = $data['delivery_type']->getId();
     unset($data['delivery_type']);
     $data['payment_type_id'] = $data['payment_type']->getId();
     unset($data['payment_type']);
     $data['status_id'] = $data['status']->getId();
     unset($data['status']);
     // start transaction
     dibi::begin();
     try {
         $this->insert($data);
         $order_id = dibi::query('SELECT LAST_INSERT_ID()')->fetchSingle();
         $order->setId($order_id);
         $order->dirty(order::UNDIRT);
         foreach (mapper::products()->findByIds(array_keys($products)) as $product) {
             dibi::query('INSERT INTO [:prefix:orders_products]', array('order_id' => $order_id, 'product_id' => $product->getId(), 'price' => $product->getPrice(), 'amount' => $products[$product->getId()]));
         }
         foreach ($visited as $_) {
             $values = array('order_id' => $order_id);
             $values['product_id'] = $_[0]->getId();
             $values['visited_at'] = date('Y-m-d H:i:s', $_[1]);
             dibi::query('INSERT INTO [:prefix:order_visited_products]', $values);
         }
         $mail = new Mail();
         $mail->setFrom(Environment::expand('%shopEmail%'))->addTo(Environment::expand('%shopEmail%'))->setSubject(__('New order'))->setBody(__('Hello, new order arrived'))->send();
         $mail = new Mail();
         $mail->setFrom(Environment::expand('%shopEmail%'))->addTo($data['email'])->setSubject(__('Your order at %s has been accepted', Environment::expand('%shopName%')))->setBody(str_replace('\\n', "\n", __('Hello, your order has been accepted.')))->send();
     } catch (Exception $e) {
         dibi::rollback();
         return FALSE;
     }
     dibi::commit();
     return TRUE;
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:44,代码来源:orders.php

示例6: upgradeDB

 public function upgradeDB()
 {
     $confDriver = ConfService::getConfStorageImpl();
     $authDriver = ConfService::getAuthDriverImpl();
     $logger = AJXP_Logger::getInstance();
     if (is_a($confDriver, "sqlConfDriver")) {
         $conf = AJXP_Utils::cleanDibiDriverParameters($confDriver->getOption("SQL_DRIVER"));
         if (!is_array($conf) || !isset($conf["driver"])) {
             return "Nothing to do";
         }
         switch ($conf["driver"]) {
             case "sqlite":
             case "sqlite3":
                 $ext = ".sqlite";
                 break;
             case "postgre":
                 $ext = ".pgsql";
                 break;
             case "mysql":
                 $ext = is_file($this->workingFolder . "/" . $this->dbUpgrade . ".mysql") ? ".mysql" : ".sql";
                 break;
             default:
                 return "ERROR!, DB driver " . $conf["driver"] . " not supported yet in __FUNCTION__";
         }
         $file = $this->dbUpgrade . $ext;
         if (!is_file($this->workingFolder . "/" . $file)) {
             return "Nothing to do.";
         }
         $sqlInstructions = file_get_contents($this->workingFolder . "/" . $file);
         $parts = array_map("trim", explode("/* SEPARATOR */", $sqlInstructions));
         $results = array();
         $errors = array();
         dibi::connect($conf);
         dibi::begin();
         foreach ($parts as $sqlPart) {
             if (empty($sqlPart)) {
                 continue;
             }
             try {
                 dibi::nativeQuery($sqlPart);
                 $results[] = $sqlPart;
             } catch (DibiException $e) {
                 $errors[] = $sqlPart . " (" . $e->getMessage() . ")";
             }
         }
         dibi::commit();
         dibi::disconnect();
         if (!count($errors)) {
             return "Database successfully upgraded";
         } else {
             return "Database upgrade failed. <br>The following statements were executed : <br>" . implode("<br>", $results) . ",<br><br> The following statements failed : <br>" . implode("<br>", $errors) . "<br><br> You should manually upgrade your DB.";
         }
     }
 }
开发者ID:Nanomani,项目名称:pydio-core,代码行数:54,代码来源:class.AjaXplorerUpgrader.php

示例7: runCreateTablesQuery

 public static function runCreateTablesQuery($p, $file)
 {
     switch ($p["driver"]) {
         case "sqlite":
         case "sqlite3":
             if (!file_exists(dirname($p["database"]))) {
                 @mkdir(dirname($p["database"]), 0755, true);
             }
             $ext = ".sqlite";
             break;
         case "mysql":
             $ext = ".mysql";
             break;
         case "postgre":
             $ext = ".pgsql";
             break;
         default:
             return "ERROR!, DB driver " . $p["driver"] . " not supported yet in __FUNCTION__";
     }
     $result = array();
     $file = dirname($file) . "/" . str_replace(".sql", $ext, basename($file));
     $sql = file_get_contents($file);
     $separators = explode("/** SEPARATOR **/", $sql);
     $allParts = array();
     foreach ($separators as $sep) {
         $explode = explode("\n", trim($sep));
         $firstLine = array_shift($explode);
         if ($firstLine == "/** BLOCK **/") {
             $allParts[] = $sep;
         } else {
             $parts = explode(";", $sep);
             $remove = array();
             for ($i = 0; $i < count($parts); $i++) {
                 $part = $parts[$i];
                 if (strpos($part, "BEGIN") && isset($parts[$i + 1])) {
                     $parts[$i] .= ';' . $parts[$i + 1];
                     $remove[] = $i + 1;
                 }
             }
             foreach ($remove as $rk) {
                 unset($parts[$rk]);
             }
             $allParts = array_merge($allParts, $parts);
         }
     }
     dibi::connect($p);
     dibi::begin();
     foreach ($allParts as $createPart) {
         $sqlPart = trim($createPart);
         if (empty($sqlPart)) {
             continue;
         }
         try {
             dibi::nativeQuery($sqlPart);
             $resKey = str_replace("\n", "", substr($sqlPart, 0, 50)) . "...";
             $result[] = "OK: {$resKey} executed successfully";
         } catch (DibiException $e) {
             $result[] = "ERROR! {$sqlPart} failed";
         }
     }
     dibi::commit();
     dibi::disconnect();
     $message = implode("\n", $result);
     if (strpos($message, "ERROR!")) {
         return $message;
     } else {
         return "SUCCESS:" . $message;
     }
 }
开发者ID:rbrdevs,项目名称:pydio-core,代码行数:69,代码来源:class.AJXP_Utils.php

示例8: onSendMailFormSubmit

 public function onSendMailFormSubmit(Form $form)
 {
     if (!$form->isValid()) {
         return;
     }
     $active = FALSE;
     try {
         dibi::begin();
         $active = TRUE;
         mapper::order_emails()->insertOne(array('order_id' => $form['order_id']->getValue(), 'subject' => $form['subject']->getValue(), 'body' => $form['body']->getValue()));
         $mail = new Mail();
         $mail->setFrom(Environment::expand('%shopName% <%shopEmail%>'))->addTo($form['to']->getValue())->setSubject($form['subject']->getValue())->setBody($form['body']->getValue())->send();
         adminlog::log(__('Sent e-mail to "%s" with subject "%s"'), $form['to']->getValue(), $form['subject']->getValue());
         $this->redirect('this');
         $this->terminate();
     } catch (RedirectingException $e) {
         dibi::commit();
         throw $e;
     } catch (Exception $e) {
         if ($active) {
             dibi::rollback();
         }
         $form->addError(__('Cannot send e-mail.'));
     }
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:25,代码来源:OrdersPresenter.php

示例9: setCategories

 public function setCategories($place_id, $data)
 {
     dibi::begin();
     dibi::query('DELETE FROM [subject_x_category] WHERE [subject_id]=%i', $place_id);
     foreach ($data as $k => $n) {
         dibi::query('INSERT INTO [subject_x_category] SET [subject_id]=%i', $place_id, ', [category_id]=%i', $n);
     }
     dibi::commit();
 }
开发者ID:soundake,项目名称:pd,代码行数:9,代码来源:Venues.php

示例10: array_map

        echo "Upgrading MYSQL database ...";
        $parts = array_map("trim", explode("/* SEPARATOR */", $dbInst));
        $results = array();
        $errors = array();
        require_once AJXP_BIN_FOLDER . "/dibi.compact.php";
        dibi::connect($test);
        dibi::begin();
        foreach ($parts as $sqlPart) {
            if (empty($sqlPart)) {
                continue;
            }
            try {
                dibi::nativeQuery($sqlPart);
                echo "<div class='upgrade_result success'>{$sqlPart} ... OK</div>";
            } catch (DibiException $e) {
                $errors[] = $e->getMessage();
                echo "<div class='upgrade_result success'>{$sqlPart} ... FAILED (" . $e->getMessage() . ")</div>";
            }
        }
        dibi::commit();
        dibi::disconnect();
    } else {
        if (is_array($test) && $test["driver"] != "mysql") {
            echo "Cannot auto-upgrade Sqlite or PostgreSql DB automatically, please review the update instructions.";
        } else {
            echo "Nothing to do for the DB";
        }
    }
} else {
    echo "Nothing to do for the DB";
}
开发者ID:thermalpaste,项目名称:pydio-core,代码行数:31,代码来源:5.3.1.php

示例11: updateOne

 /**
  * Update
  */
 public function updateOne(array $values)
 {
     try {
         dibi::begin();
         $product = array();
         $product['price'] = intval($values['price']);
         if (isset($values['manufacturer_id'])) {
             $product['manufacturer_id'] = $values['manufacturer_id'] == 0 ? NULL : intval($values['manufacturer_id']);
         }
         if (isset($values['category_id'])) {
             $product['category_id'] = $values['category_id'] == 0 ? NULL : intval($values['category_id']);
         }
         $product_id = intval($values['id']);
         if (isset($values['availability_id'])) {
             $product['availability_id'] = $values['availability_id'] == 0 ? NULL : intval($values['availability_id']);
         }
         if (isset($values['code'])) {
             $product['code'] = empty($values['code']) ? NULL : $values['code'];
         }
         unset($values['price'], $values['manufacturer_id'], $values['category_id'], $values['availability_id'], $values['id'], $values['code']);
         dibi::query('UPDATE [:prefix:products] SET', $product, 'WHERE [id] = %i', $product_id);
         $change = array('product_id' => $product_id, 'price' => $product['price'], 'changed_at' => new DibiVariable('NOW()', 'sql'));
         dibi::query('INSERT INTO [:prefix:price_changes]', $change);
         if (isset($values['picture_id'])) {
             $values['picture_id'] = $values['picture_id'] == 0 ? NULL : intval($values['picture_id']);
         }
         if (isset($values['meta_keywords']) && empty($values['meta_keywords'])) {
             $values['meta_keywords'] = NULL;
         }
         if (isset($values['meta_description']) && empty($values['meta_description'])) {
             $values['meta_description'] = NULL;
         }
         if (isset($values['content']) && empty($values['content'])) {
             $values['content'] = NULL;
         }
         if (!empty($values)) {
             $where = array();
             $where['ref_id'] = $product_id;
             $where['ref_type'] = pages::PRODUCT;
             dibi::query('UPDATE [:prefix:pages] SET', $values, 'WHERE %and', $where);
         }
         dibi::commit();
         //<fulltext>
         fulltext::dirty($product_id, TRUE);
         //</fulltext>
         return TRUE;
     } catch (Exception $e) {
         dibi::rollback();
         return FALSE;
     }
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:54,代码来源:products.php

示例12: insert

 public function insert(array $data)
 {
     if ($this->config['useAcl']) {
         // check rights
         if (!$this->user->isAllowed(Acl::RESOURCE_USER, Acl::PRIVILEGE_ADD)) {
             throw new OperationNotAllowedException();
         }
     }
     $data['token'] = md5($data['email'] . $data['username']);
     $data['registered'] = dibi::datetime();
     if (isset($data['roles'])) {
         $roles = $data['roles'];
         unset($data['roles']);
     }
     if (isset($data['client_logo'])) {
         $clientLogo = $data['client_logo'];
         unset($data['client_logo']);
     }
     // create user and update his password - needed because getHasherParamsFromUserData() requires $userId
     try {
         dibi::begin();
         // save random password temporarily
         $realPassword = $data['password'];
         $data['password'] = Basic::randomizer(40);
         $userId = parent::insert($data);
         $data['password'] = $realPassword;
         $this->update($userId, $data);
         dibi::commit();
     } catch (DibiDriverException $e) {
         dibi::rollback();
         throw $e;
     }
     if (isset($roles)) {
         $this->getRolesModel()->updateUserRoles($userId, (array) $roles);
     }
     if (!empty($clientLogo)) {
         $this->saveClientLogo($userId, $clientLogo);
     }
     return $userId;
 }
开发者ID:radypala,项目名称:maga-website,代码行数:40,代码来源:UsersModel.php

示例13: addEditOnFormSubmitted

 public function addEditOnFormSubmitted(NAppForm $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 = UserModel::insert($values);
             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']);
             unset($values['password2']);
             //                dibi::query('UPDATE ['.TABLE_USERS.'] SET %a WHERE id=%i;', $values, $id);
             UserModel::update($id, $values);
             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:oaki,项目名称:demoshop,代码行数:63,代码来源:UsersPresenter.php

示例14: updateOne

 /**
  * Update
  * @param array
  * @return bool
  */
 public function updateOne(array $values)
 {
     try {
         $values['initial'] = (bool) $values['initial'];
         dibi::begin();
         if ($values['initial']) {
             dibi::query('UPDATE [:prefix:order_statuses] SET [initial] = %b', FALSE);
         }
         $id = intval($values['id']);
         unset($values['id']);
         dibi::query('UPDATE [:prefix:order_statuses] SET', $values, 'WHERE [id] = %i', $id);
         dibi::commit();
         return TRUE;
     } catch (Excetion $e) {
         return FALSE;
     }
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:22,代码来源:order_statuses.php

示例15: setPrimary

 public function setPrimary($file_id, $event_id)
 {
     dibi::begin();
     dibi::query('UPDATE [event_x_file] SET [first] = 0 WHERE [event_id] = %i', $event_id);
     dibi::query('UPDATE [event_x_file] SET [first] = 1 WHERE [event_id] = %i', $event_id, " AND [file_id]=%i", $file_id);
     dibi::commit();
 }
开发者ID:soundake,项目名称:pd,代码行数:7,代码来源:Events.php


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