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


PHP DBConnect::rollback方法代码示例

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


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

示例1: post_update


//.........这里部分代码省略.........
        }
        if (!is_bool($new_order) && !is_numeric($new_order))
        {
            throw new DBForumException(
                    '$new_order must be numeric or boolean');
        }
        if (!is_bool($new_content))
        {
            self::validate_content($new_content, $this->post_datatype);
        }
        if (!is_bool($metadata) && !is_string($metadata))
        {
            throw new DBDataTypeException(
                    '$metadata must be a string');
        }
        if (is_bool($new_content) && 
            is_bool($new_parent) &&
            is_bool($new_order) &&
            is_bool($metadata))
        {
            return;
        }
        try
        {
            if (!is_bool($new_parent) || !is_bool($new_order) || !is_bool($metadata))
            {
                if (is_bool($new_order) && !is_bool($new_parent))
                {
                    $new_order = $this->db->quick_query(
                            "SELECT max(".self::POSTORDER.") FROM ".self::FCORE_FORUM_POST." WHERE
                                ".self::POSTPARENT."=$new_parent AND
                                ".self::FORUM_ID."=$this->forum_id", true);
                    if ($new_order == null)
                    {
                        $new_order = 0;
                    }
                    else
                    {
                        $new_order = $new_order[0]["max(".self::POSTORDER.")"];
                        $new_order++;
                    }
                }
                $set = "";
                if (!is_bool($new_parent))
                {
                    if ($new_parent != 0)
                    {
                        $count = $this->db->quick_query(
                                "SELECT COUNT(*) FROM ".self::FCORE_FORUM_POST." WHERE
                                    ".self::FORUM_ID."=$this->forum_id &&
                                    ".self::POST_ID."=$new_parent",
                                true);
                        $count = $count[0]["COUNT(*)"];
                        if ($count == 0)
                        {
                            throw new Exception(
                                    "the parent id does not exist in this forum");
                        }
                    }
                    $set .= self::POSTPARENT."=$new_parent";
                    if (!is_bool($new_order) || !is_bool($metadata))
                    {
                        $set .= ",";
                    }
                }
                if (!is_bool($new_order))
                {
                    $set .= self::POSTORDER."=$new_order";
                    if (!is_bool($metadata))
                    {
                        $set .= ",";
                    }
                }
                if (!is_bool($metadata))
                {
                    $set .= self::METADATA."='$metadata'";
                }

                $this->db->quick_query(
                        "UPDATE ".self::FCORE_FORUM_POST." SET
                            $set
                            WHERE
                            ".self::POST_ID."=$post_id AND
                            ".self::FORUM_ID."=$this->forum_id");
                $this->db->commit();
            }
            if (is_string($new_content))
            {
                DBDataType::UpdateContentFromOrigin(
                        $new_content,
                        self::build_datatype_origin($this->origin_type),
                        $post_id);
            }
        }
        catch(Exception $e)
        {
            $this->db->rollback();
            throw new DBForumException($e->getMessage());
        }
    }
开发者ID:rexfleischer,项目名称:web_dev,代码行数:101,代码来源:DBForum.php

示例2: delete_all

 /**
  * 
  */
 public function delete_all()
 {
     try
     {
         $this->conn->quick_query(
                 "DELETE FROM ".$this->config_map[self::DB_TABLE_NAME]
                 );
         $this->conn->commit();
     }
     catch(DBConnectException $e)
     {
         $this->conn->rollback();
         FCore::GetLogger()->log(Logger::LEVEL_ERROR, $e->getMessage());
         throw new DBFactoryException(
                 "An Error Occurred While Attempting To Delete: ", $e);
     }
 }
开发者ID:rexfleischer,项目名称:web_dev,代码行数:20,代码来源:DBFactory.php


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