Overview

Namespaces

  • Application
    • Controller
    • Model
      • DAO
        • Impl
      • Service
        • Impl
  • Define
    • Core
    • DBDrivers
    • Exceptions
    • IUtilities
    • Traits
    • Utilities
  • None

Classes

  • Application\Controller\ApplicationController
  • Application\Controller\ErrorController
  • Application\Controller\IndexController
  • Application\Model\DAO\ApplicationDAO
  • Application\Model\DAO\Impl\IndexDAO
  • Application\Model\Service\ApplicationService
  • Application\Model\Service\Impl\IndexService
  • Define\Core\BaseController
  • Define\Core\BaseDAO
  • Define\Core\BaseModel
  • Define\Core\BaseService
  • Define\Core\Framework
  • Define\Core\ObjectContainer
  • Define\Core\Router
  • Define\Core\View
  • Define\DBDrivers\DatabaseBean
  • Define\DBDrivers\DatabaseFactory
  • Define\DBDrivers\MONGODBDriver
  • Define\DBDrivers\MSSQLDriver
  • Define\DBDrivers\MYSQLDriver
  • Define\DBDrivers\MYSQLIDriver
  • Define\DBDrivers\ORACLEDriver
  • Define\DBDrivers\PDODriver
  • Define\DBDrivers\POSTGREDriver
  • Define\DBDrivers\SQLITEDriver
  • Define\IUtilities\PasswordHelper
  • Define\Utilities\ErrorExceptionHandler
  • Define\Utilities\Localization
  • Define\Utilities\Logger
  • Define\Utilities\Session
  • PHPMailer
  • SMTP

Interfaces

  • Define\Core\IBaseDAO
  • Define\Core\IBaseModel
  • Define\Core\IBaseService
  • Define\Core\IDefine
  • Define\Core\IRouter
  • Define\Core\IView
  • Define\DBDrivers\IDatabase
  • Define\Exceptions\IException
  • Define\Utilities\IUtilities

Traits

  • Define\Traits\SingletonTrait

Exceptions

  • Define\Exceptions\FileNotFoundException
  • Define\Exceptions\FrameworkException
  • Define\Exceptions\LoggerException
  • Define\Exceptions\NullPointerException
  • Define\Exceptions\RuntimeException
  • phpmailerException

Functions

  • __autoload
  • Overview
  • Namespace
  • Class
 1: <?php
 2: namespace Define\DBDrivers;
 3: use Define\Core\ObjectContainer;
 4: use Define\Exceptions\FrameworkException;
 5: 
 6: if(!defined('DIRECT_ACCESS')) {
 7:     die("Direct access is forbidden.");
 8: }
 9: 
10: /**
11:  * DATABASE FACTORY
12:  *
13:  * Database factory class for retriving the instance of the database driver class.
14:  *  
15:  * @category Define
16:  * @package DBDrivers
17:  * @author Nitesh Apte <me@niteshapte.com>
18:  * @copyright 2015 Nitesh Apte
19:  * @version 1.0.0
20:  * @since 1.0.0
21:  * @license https://www.gnu.org/licenses/gpl.txt GNU General Public License v3
22:  * 
23:  * This program is free software: you can redistribute it and/or modify
24:  * it under the terms of the GNU General Public License as published by
25:  * the Free Software Foundation, either version 3 of the License, or
26:  * (at your option) any later version.
27:  *
28:  * This program is distributed in the hope that it will be useful,
29:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
30:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31:  * GNU General Public License for more details.
32:  *
33:  * You should have received a copy of the GNU General Public License
34:  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
35:  */
36: class DatabaseFactory {
37:     
38:     /**
39:      * Returns the instance of type IDatabase and also makes connection.
40:      * 
41:      * @param string $databaseType
42:      * @throws FrameworkException
43:      * @return Instance of IDatabase
44:      */
45:     public static function create($databaseType = 'MYSQLI') {
46:         $container = ObjectContainer::getInstance();
47:         $bean = $container->offsetGet($databaseType);
48:         $instance = NULL;
49:         switch ($databaseType) {
50:             case 'MYSQL':
51:                 $instance = MYSQLDriver::getInstance();
52:             break;
53:             
54:             case 'MYSQLI':
55:                 $instance = MYSQLIDriver::getInstance();
56:             break;
57:                 
58:             case 'PDO':
59:                 $instance = PDODriver::getInstance();
60:             break;
61:             
62:             case 'ORACLE':
63:                 $instance = ORACLEDriver::getInstance();
64:             break;
65:             
66:             case 'MSSQL':
67:                 $instance = MSSQLDriver::getInstance();
68:             break;
69:             
70:             case 'PGSQL':
71:                 $instance = POSTGREDriver::getInstance();
72:             break;
73:             
74:             case 'SQLITE':
75:                 $instance = SQLITEDriver::getInstance();
76:             break;
77:             
78:             case 'MARIA':
79:                 
80:             break;
81:             
82:             case 'MONGO':
83:                 
84:             break;
85:             
86:             default:
87:                 throw new FrameworkException("Unsupported database driver {$databaseType}");    
88:             
89:         }
90:         if(!$instance instanceof IDatabase) {
91:             throw new FrameworkException("Make sure {$databaseType} Driver class is of type IDatabase");
92:         }
93:         $instance->getConnection($bean);
94:         return $instance;
95:     }
96: }
API documentation generated by ApiGen