155. public function __construct(array $config = [])
156. {
157. $this->defaultConfig = Config::default('ZN\Database\DatabaseDefaultConfiguration')
158. ::get('Database', 'database');
159. $this->config = array_merge($this->defaultConfig, $config);
160. $this->db = $this->runDriver();
161. $this->prefix = $this->config['prefix'];
162. Properties::$prefix = $this->prefix;
163.
164. $this->db->connect($this->config);
165. }
166.
167. /**
168. * Magic Debug Info
169. */
170. public function __debugInfo()
171. {
172. return ['return' => $this->stringQuery ?: 'This is a general object, please call the sub method!'];
173. }
174.
26. //const exclude = ['user/login'];
27. //const include = ['home', 'product', 'contact'];
28. public function main()
29. {
30. # Sets max execution time 0
31. InitializeModel\Ini::maxExecutionTime();
32.
33. Theme::active( 'Perpa' );
34.
35. $settings = DB::whereId( 1 )->settingsRow();
36. $totalSector = DB::query("SELECT COUNT(DISTINCT id) FROM nace_group")->value();
37. $totalCompany = DB::query("SELECT COUNT(*) FROM company WHERE is_active = 1")->value();
38.
39. Masterpage::headPage( 'Sections/head' )
40. ->bodyPage( 'Sections/body' )
41. ->title( $settings->title );
42.
43.
44. $popupSplash = \Perpa\Splash::result(11)->row();
45. $popupSplashDisplay = Cookie::popupSplashDisplay() ?? false;
139. $this->connect = new MySQLi;
140.
141. $this->connect->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true);
142. $this->connect->ssl_set($ssl['key'] ?? NULL, $ssl['cert'] ?? NULL, $ssl['ca'] ?? NULL, $ssl['capath'] ?? NULL, $ssl['cipher'] ?? NULL);
143. $this->connect->real_connect($host, $user, $pass, $db, $port, NULL, MYSQLI_CLIENT_SSL);
144. }
145. // @codeCoverageIgnoreEnd
146. else
147. {
148. $this->connect = new MySQLi($host, $user, $pass, $db, $port);
149. }
150. restore_error_handler();
151.
152. if( $this->connect->connect_errno )
153. {
154. throw new ConnectionErrorException(NULL, $this->connect->connect_error); // @codeCoverageIgnore
155. }
156.
157. mysqli_report(MYSQLI_REPORT_OFF);
158.