cvs: pear /MDB2/MDB2/Driver mysql.php mysqli.php

From: Date: Thu, 08 Feb 2007 09:36:44 +0000
Subject: cvs: pear /MDB2/MDB2/Driver mysql.php mysqli.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-44581@lists.php.net to get a copy of this message
quipo Thu Feb 8 09:36:44 2007 UTC Modified files: /pear/MDB2/MDB2/Driver mysql.php mysqli.php Log: extracted method _getServerCapabilities(), used in connect() and in beginTransaction()

http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/mysql.php?r1=1.173&r2=1.174&diff_format=u Index: pear/MDB2/MDB2/Driver/mysql.php diff -u pear/MDB2/MDB2/Driver/mysql.php:1.173 pear/MDB2/MDB2/Driver/mysql.php:1.174 --- pear/MDB2/MDB2/Driver/mysql.php:1.173 Sat Jan 6 21:53:54 2007 +++ pear/MDB2/MDB2/Driver/mysql.php Thu Feb 8 09:36:44 2007 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mysql.php,v 1.173 2007/01/06 21:53:54 quipo Exp $ +// $Id: mysql.php,v 1.174 2007/02/08 09:36:44 quipo Exp $ // /** @@ -214,6 +214,7 @@ function beginTransaction($savepoint = null) { $this->debug('Starting transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint)); + $this->_getServerCapabilities(); if (!is_null($savepoint)) { if (!$this->supports('savepoints')) { return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, @@ -490,28 +491,8 @@ $this->supported['prepared_statements'] = 'emulated'; $this->start_transaction = false; $this->varchar_max_length = 255; - - $server_info = $this->getServerVersion(); - if (is_array($server_info)) { - if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.1.0', '<')) { - $this->supported['sub_selects'] = true; - $this->supported['prepared_statements'] = true; - } - - if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.0.14', '<') - || !version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.1.1', '<') - ) { - $this->supported['savepoints'] = true; - } - - if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.0.11', '<')) { - $this->start_transaction = true; - } - - if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '5.0.3', '<')) { - $this->varchar_max_length = 65532; - } - } + + $this->_getServerCapabilities(); return MDB2_OK; } @@ -742,6 +723,44 @@ } // }}} + // {{{ _getServerCapabilities() + + /** + * Fetch some information about the server capabilities + * (transactions, subselects, prepared statements, etc). + * + * @access private + */ + function _getServerCapabilities() + { + static $already_checked = false; + if (!$already_checked) { + $already_checked = true; + $server_info = $this->getServerVersion(); + if (is_array($server_info)) { + if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.1.0', '<')) { + $this->supported['sub_selects'] = true; + $this->supported['prepared_statements'] = true; + } + + if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.0.14', '<') + || !version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.1.1', '<') + ) { + $this->supported['savepoints'] = true; + } + + if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.0.11', '<')) { + $this->start_transaction = true; + } + + if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '5.0.3', '<')) { + $this->varchar_max_length = 65532; + } + } + } + } + + // }}} // {{{ prepare() /** http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/mysqli.php?r1=1.152&r2=1.153&diff_format=u Index: pear/MDB2/MDB2/Driver/mysqli.php diff -u pear/MDB2/MDB2/Driver/mysqli.php:1.152 pear/MDB2/MDB2/Driver/mysqli.php:1.153 --- pear/MDB2/MDB2/Driver/mysqli.php:1.152 Sat Jan 6 21:53:54 2007 +++ pear/MDB2/MDB2/Driver/mysqli.php Thu Feb 8 09:36:44 2007 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mysqli.php,v 1.152 2007/01/06 21:53:54 quipo Exp $ +// $Id: mysqli.php,v 1.153 2007/02/08 09:36:44 quipo Exp $ // /** @@ -215,6 +215,7 @@ function beginTransaction($savepoint = null) { $this->debug('Starting transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint)); + $this->_getServerCapabilities(); if (!is_null($savepoint)) { if (!$this->supports('savepoints')) { return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, @@ -477,28 +478,8 @@ $this->supported['prepared_statements'] = 'emulated'; $this->start_transaction = false; $this->varchar_max_length = 255; - - $server_info = $this->getServerVersion(); - if (is_array($server_info)) { - if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.1.0', '<')) { - $this->supported['sub_selects'] = true; - $this->supported['prepared_statements'] = true; - } - - if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.0.14', '<') - || !version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.1.1', '<') - ) { - $this->supported['savepoints'] = true; - } - - if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.0.11', '<')) { - $this->start_transaction = true; - } - - if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '5.0.3', '<')) { - $this->varchar_max_length = 65532; - } - } + + $this->_getServerCapabilities(); return MDB2_OK; } @@ -748,6 +729,44 @@ } // }}} + // {{{ _getServerCapabilities() + + /** + * Fetch some information about the server capabilities + * (transactions, subselects, prepared statements, etc). + * + * @access private + */ + function _getServerCapabilities() + { + static $already_checked = false; + if (!$already_checked) { + $already_checked = true; + $server_info = $this->getServerVersion(); + if (is_array($server_info)) { + if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.1.0', '<')) { + $this->supported['sub_selects'] = true; + $this->supported['prepared_statements'] = true; + } + + if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.0.14', '<') + || !version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.1.1', '<') + ) { + $this->supported['savepoints'] = true; + } + + if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '4.0.11', '<')) { + $this->start_transaction = true; + } + + if (!version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '5.0.3', '<')) { + $this->varchar_max_length = 65532; + } + } + } + } + + // }}} // {{{ prepare() /**
« previous php.pear.cvs (#44581) next »