OSDN Git Service

add ACS webapp, sql, htdocs
[acs/acs.git] / webapp / lib / database / common / ConnectionFactory.class.php
diff --git a/webapp/lib/database/common/ConnectionFactory.class.php b/webapp/lib/database/common/ConnectionFactory.class.php
new file mode 100644 (file)
index 0000000..4cf4f03
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+require_once(MO_PEAR_DIR . "/DB.php");
+
+class ConnectionFactory
+{
+       function getConnection()
+       {
+               $dsn = array (
+                       'phptype'  => DB_PHPTYPE,
+                       'hostspec' => DB_HOSTSPEC,
+                       'port'     => DB_PORT,
+                       'database' => DB_DATABASE,
+                       'username' => DB_USERNAME,
+                       'password' => DB_PASSWORD
+               );
+
+               $options = array (
+                       'debug' => 2,
+               );
+               
+               $db =& DB::connect($dsn, $options);
+               if (DB::isError($db)) {
+                       throw new ApplicationException($db->getMessage());
+               }
+
+               return $db;
+       }
+}
+?>
\ No newline at end of file