1- <?php namespace slqsl \slqsl ;
1+ <?php namespace slsql \Slsql ;
2+
3+ use slsql \Config ;
4+ use \Error ;
5+ use \PDO ;
26
37/**
48 * WTFPL License (http://www.wtfpl.net/) - https: //github.com/CrBast/PHP-SQL_SimpleLife/blob/master/LICENSE
@@ -114,7 +118,7 @@ public function createDB()
114118
115119 /**
116120 * Send Request.
117- * the parameters are in the .env file
121+ * the parameters are in the Config class file (slsql\Config)
118122 *
119123 * Return :
120124 * [value] = result,
@@ -124,7 +128,7 @@ public function createDB()
124128 public static function go ($ request , $ array = array ())
125129 {
126130 try {
127- $ db = slsql ::getPDO ();
131+ $ db = Slsql ::getPDO ();
128132 $ stmt = $ db ->prepare ($ request );
129133 $ stmt ->execute ($ array );
130134 //var_dump($stmt);
@@ -137,7 +141,7 @@ public static function go($request, $array = array())
137141
138142 /**
139143 * Send Transaction.
140- * the parameters are in the .env file
144+ * the parameters are in the Config class file (slsql\Config)
141145 *
142146 * Return :
143147 * [value] = result,
@@ -146,7 +150,7 @@ public static function go($request, $array = array())
146150 */
147151 public static function goT (SLTransaction $ trans )
148152 {
149- $ db = slsql ::getPDO ();
153+ $ db = Slsql ::getPDO ();
150154 try {
151155 $ db ->beginTransaction ();
152156 foreach ($ trans ->get () as $ transaction ) {
@@ -164,13 +168,11 @@ public static function goT(SLTransaction $trans)
164168
165169 private static function getPDO ()
166170 {
167- try {
168- require '../.env ' ;
169- } catch (Exception $ e ) {
170- throw new Error ("Error Processing Request " );
171+ if (!class_exists ("\slsql\Config " )) {
172+ throw new Error ("Cannot find <\slsql\Config> " );
171173 }
172174 try {
173- $ db = new PDO ($ env [ ' DBType ' ] . ':dbname= ' . $ env [ ' DBName ' ] . ';host= ' . $ env [ ' Host ' ], $ env [ ' User ' ], $ env [ ' Password ' ] );
175+ $ db = new PDO (Config::dbType . ':dbname= ' . Config::dbName . ';host= ' . Config::host, Config::user, Config::password );
174176 $ db ->setAttribute (PDO ::ATTR_ERRMODE , PDO ::ERRMODE_EXCEPTION );
175177 return $ db ;
176178 } catch (PDOException $ e ) {
@@ -195,7 +197,7 @@ public function get()
195197
196198 public function go ()
197199 {
198- return slsql ::goT ($ this );
200+ return Slsql ::goT ($ this );
199201 }
200202}
201203
0 commit comments