3 * Factory class for data objects
5 usingPackage ('coreexceptions');
7 static public $TYPES = array ('postgresql', 'mysql', 'mysqli', 'null');
8 static private $instance = false;
11 * returning if the set DB type is supported
16 public static function validType ($type) {
17 if (in_array(strtolower($type), sqlFactory
::$TYPES))
23 * returns the cuurent instance of the DB connection
24 * or a new connection of type $incString
26 * @param string $incString
27 * @return fooSqlDriverA
30 static public function &connect($incString) {
31 if (!sqlFactory
::validType ($incString)) {
32 sqlFactory
::$instance = new nullSql();
33 // throw new tsExceptionUnimplemented ('The database type is invalid');
36 if(!(sqlFactory
::$instance instanceof fooSqlDriverA
)) {
37 if (stristr($incString, 'mysql')) {
38 sqlFactory
::$instance = new mySqlIm ();
39 } /*elseif (stristr ($incString, 'mysql')) {
40 sqlFactory::$instance = new mySql ();
41 }*/ elseif (stristr ($incString, 'postgresql')) {
42 sqlFactory
::$instance = new postgreSql ();
43 } elseif (stristr ($incString, 'sqlserv')) {
44 sqlFactory
::$instance = new nullSql (); // Sql server not implemented
47 if (sqlFactory
::$instance->error
) {
48 sqlFactory
::$instance = new nullSql ();
51 return sqlFactory
::$instance;