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.
1346. */
1347. public function query(string $query, array $secure = [])
1348. {
1349. $secure = $this->secure ?: $secure; $this->secure = [];
1350. $caching = $this->caching; $this->caching = [];
1351. $tableName = $this->tableName; $this->tableName = '';
1352. $jsonDecode = $this->jsonDecode; $this->jsonDecode = [];
1353. $paging = $this->paging;
1354.
1355. return (new self($this->config))->setQueryByDriver($query, $secure,
1356. [
1357. 'caching' => $caching,
1358. 'tableName' => $tableName,
1359. 'jsonDecode' => $jsonDecode,
1360. 'paging' => $paging
1361. ]);
1362. }
1363.
1364. /**
1365. * Exec Basic Query
800. }
801.
802. if( $this->transaction === true )
803. {
804. $this->transactionQueries[] = $finalQuery;
805.
806. return $this;
807. }
808.
809. return $this->$returnQuery($finalQuery, $this->secure);
810. }
811.
812. /**
813. * Duplicate Check
814. *
815. * @param string ...$args
816. *
817. * @return DB
818. */
819. public function duplicateCheck(...$args) : DB
21.
22.
23.
24.
25. static public function result(Int $area_id = 0, $where = [])
26. {
27. $where[] = ['int:is_active', true];
28. $where[] = ['exp:area_id', $area_id];
29. $where[] = ['exp:CURDATE() BETWEEN', 'start_date AND end_date'];
30. $splash = DB::where($where)->get('splash');
31. return $splash;
32. }
33.
34.
35.
36. static public function splash_picture($splash, $options = array())
37. {
38. $options['title'] = $splash->title;
39. return Html::image(self::splash_path($splash), NULL, NULL, $options);
40. }
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;
46.
47. if( $popupSplash && Cookie::splashDisplay() == false )
48. {
49. Cookie::time( 60 * 60 * 24 )->insert( 'popupSplashDisplay', true );
50. }
51. $user = User::data();
52. # Sabitler
53. self::defines($user);
54. //->attributes(['body' => ['class' => 'show-nav home-page yo-anim-enabled']]);
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.
159. if( ! empty($this->config['charset'] ) ) $this->query("SET NAMES '".$this->config['charset']."'");
160. if( ! empty($this->config['charset'] ) ) $this->query('SET CHARACTER SET '.$this->config['charset']);
161. if( ! empty($this->config['collation']) ) $this->query('SET COLLATION_CONNECTION = "'.$this->config['collation'].'"');
162. }
163.
164. /**