ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilDBWrapperFactory.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
5 include_once ("./Services/Database/classes/class.ilDB.php");
6 
16 {
17  static function getWrapper($a_type, $a_inactive_mysqli = null)
18  {
19  global $ilClientIniFile;
20 
21  if ($a_type == "" && is_object($ilClientIniFile))
22  {
23  $a_type = $ilClientIniFile->readVariable("db","type");
24  }
25  if ($a_type == "")
26  {
27  $a_type = "mysql";
28  }
29 
30  switch ($a_type)
31  {
32  case "mysql":
33  include_once("./Services/Database/classes/class.ilDBMySQL.php");
34  $ilDB = new ilDBMySQL();
35 
36  if($a_inactive_mysqli === null &&
37  is_object($ilClientIniFile))
38  {
39  $a_inactive_mysqli = $ilClientIniFile->readVariable("db","inactive_mysqli");
40  }
41 
42  // default: use mysqli driver if not prevented by ini setting
43  if(!(bool)$a_inactive_mysqli)
44  {
45  $ilDB->setSubType("mysqli");
46  }
47 
48  break;
49 
50  case "innodb":
51  include_once("./Services/Database/classes/class.ilDBInnoDB.php");
52  $ilDB = new ilDBInnoDB();
53 
54  if($a_inactive_mysqli === null &&
55  is_object($ilClientIniFile))
56  {
57  $a_inactive_mysqli = $ilClientIniFile->readVariable("db","inactive_mysqli");
58  }
59 
60  // default: use mysqli driver if not prevented by ini setting
61  if(!(bool)$a_inactive_mysqli)
62  {
63  $ilDB->setSubType("mysqli");
64  }
65 
66  break;
67 
68  case "postgres":
69  include_once("./Services/Database/classes/class.ilDBPostgreSQL.php");
70  $ilDB = new ilDBPostgreSQL();
71  break;
72 
73  case "oracle":
74  include_once("./Services/Database/classes/class.ilDBOracle.php");
75  $ilDB = new ilDBOracle();
76  break;
77  }
78 
79  return $ilDB;
80  }
81 }