keethebest 发表于 2013-9-22 17:08:34

连接mysql,PDO不支持事务处理吗?

看到pdo_driver.php有这么一段代码:

        function __construct($params)
        {
                parent::__construct($params);
               
                // clause and character used for LIKE escape sequences
                if (strpos($this->hostname, 'mysql') !== FALSE)
                {
                        $this->_like_escape_str = '';
                        $this->_like_escape_chr = '';
                       
                        //Prior to this version, the charset can't be set in the dsn
                        if(is_php('5.3.6'))
                        {
                                $this->hostname .= ";charset={$this->char_set}";
                        }
                       
                        //Set the charset with the connection options
                        $this->options['PDO::MYSQL_ATTR_INIT_COMMAND'] = "SET NAMES {$this->char_set}";
                }
                else if (strpos($this->hostname, 'odbc') !== FALSE)
                {
                        $this->_like_escape_str = " {escape '%s'} ";
                        $this->_like_escape_chr = '!';
                }
                else
                {
                        $this->_like_escape_str = " ESCAPE '%s' ";
                        $this->_like_escape_chr = '!';
                }
               
                $this->hostname .= ";dbname=".$this->database;
               
                $this->trans_enabled = FALSE;

                $this->_random_keyword = ' RND('.time().')'; // database specific random keyword
        }



$this->trans_enabled = FALSE;

这不是关掉事务的控制功能了吗?PDO不支持事务操作?



        function trans_begin($test_mode = FALSE)
        {
                if ( ! $this->trans_enabled)
                {
                        return TRUE;
                }

                // When transactions are nested we only begin/commit/rollback the outermost ones
                if ($this->_trans_depth > 0)
                {
                        return TRUE;
                }

                // Reset the transaction failure flag.
                // If the $test_mode flag is set to TRUE transactions will be rolled back
                // even if the queries produce a successful result.
                $this->_trans_failure = (bool) ($test_mode === TRUE);

                return $this->conn_id->beginTransaction();
        }

combook 发表于 2016-5-24 11:32:45

我还没搞明白如何使用PDO连接数据库。
页: [1]
查看完整版本: 连接mysql,PDO不支持事务处理吗?