CVS update: /cowiki/includes/cowiki/class/dao/
[email protected] 12 Apr 2005 18:45:35 -0000
| Newsgroups | gmane.comp.php.cowiki.cvs |
|---|---|
| Message-ID | <[email protected]> |
User: dgorski Date: 05/04/12 11:45:35 Modified: /cowiki/includes/cowiki/class/dao/ class.DAOFactory.php Log: Checks for schemas: mysql, mysqli, mysql+innodb, mysqli+innodb File Changes: Directory: /cowiki/includes/cowiki/class/dao/ ============================================= File [changed]: class.DAOFactory.php Url: http://cowiki.tigris.org/source/browse/cowiki/includes/cowiki/class/dao/class.DAOFactory.php?r1=1.13&r2=1.14 Delta lines: +34 -28 --------------------- --- class.DAOFactory.php 26 Jan 2005 01:36:24 -0000 1.13 +++ class.DAOFactory.php 12 Apr 2005 18:45:35 -0000 1.14 @@ -2,7 +2,7 @@ /** * - * $Id: class.DAOFactory.php,v 1.13 2005/01/26 01:36:24 dgorski Exp $ + * $Id: class.DAOFactory.php,v 1.14 2005/04/12 18:45:35 dgorski Exp $ * * This file is part of coWiki. coWiki is free software under the terms of * the GNU General Public License (GPL). Read the LICENSE file. If you did @@ -17,7 +17,7 @@ * @author Daniel T. Gorski, <[email protected]> * @copyright (C) Daniel T. Gorski, {@link http://www.develnet.org} * @license http://www.gnu.org/licenses/gpl.html - * @version $Revision: 1.13 $ + * @version $Revision: 1.14 $ * */ @@ -97,27 +97,10 @@ // ---------------------------------------------------------------- - if ($UriInfo->get('scheme') == 'mysql') { - - if (!function_exists('mysql_connect')) { - - // {{{ DEBUG }}} - Logger::error('MySQL extension not available.'); - - $Context->addError(540, 'MySQL extension not available'); - $Context->terminate(); - } - + if ($this->isValidSqlScheme($UriInfo->get('scheme'))) { return DocumentDAO::getInstance(); } - // ---------------------------------------------------------------- - - // {{{ DEBUG }}} - Logger::error('Unknown URL scheme "'.$UriInfo->get('scheme').'"'); - - // API error - $Context->addError(550, $UriInfo->get('scheme')); $Context->terminate(); } @@ -162,28 +145,51 @@ // ---------------------------------------------------------------- - if ($UriInfo->get('scheme') == 'mysql') { + if ($this->isValidSqlScheme($UriInfo->get('scheme'))) { + return UserDAOMySQL::getInstance(); + } + $Context->terminate(); + } + + // -------------------------------------------------------------------- + + private function isValidSqlScheme($sScheme) { + + if ($sScheme == 'mysql' || $sScheme == 'mysql+innodb') { if (!function_exists('mysql_connect')) { // {{{ DEBUG }}} Logger::error('MySQL extension not available.'); $Context->addError(540, 'MySQL extension not available'); - $Context->terminate(); + return false; } - return UserDAOMySQL::getInstance(); + return true; + } + + if ($sScheme == 'mysqli' || $sScheme == 'mysqli+innodb') { + if (!function_exists('mysqli_connect')) { + + // {{{ DEBUG }}} + Logger::error('MySQLi extension not available.'); + + $Context->addError(540, 'MySQLi extension not available'); + return false; + } + + return true; } // ---------------------------------------------------------------- // {{{ DEBUG }}} - Logger::error('Unknown URL scheme "'.$UriInfo->get('scheme').'"'); + Logger::error('Unknown URL scheme "'.$sScheme.'"'); // API error - $Context->addError(554, $UriInfo->get('scheme')); - $Context->terminate(); + $Context->addError(550, $sScheme); + return false; } } // of class