3 * Factory class for data objects
7 static public $TYPES = array ('postgresql', 'mysql','mysqli');
8 static private $instance = false;
11 * returning if the set DB type is supported
16 public static function validType ($type) {
17 if (in_array($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 interfaceSql
30 static public function connect($incString) {
31 if (!sqlFactory
::validType ($incString)) {
32 sqlFactory
::$instance = new nullSql();
35 if(!(sqlFactory
::$instance instanceof interfaceSql
)) {
36 if (stristr($incString, 'mysqli')) {
37 sqlFactory
::$instance = new mySqlIm ();
38 } elseif (stristr ($incString, 'mysql')) {
39 sqlFactory
::$instance = new mySql ();
40 } elseif (stristr ($incString, 'postgresql')) {
41 sqlFactory
::$instance = new nullSql (); // postgresql not implemented
42 } elseif (stristr ($incString, 'sqlserv')) {
43 sqlFactory
::$instance = new nullSql (); // Sql server not implemented
46 if (sqlFactory
::$instance->error
) {
47 sqlFactory
::$instance = new nullSql ();
50 return sqlFactory
::$instance;