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
1760. *
1761. * @param bool $real = false
1762. *
1763. * @return int
1764. */
1765. public function totalRows(bool $total = false) : int
1766. {
1767. if( $total === true )
1768. {
1769. return $this->query($this->db->cleanLimit($this->stringQuery()))->totalRows();
1770. }
1771.
1772. return $this->db->numRows();
1773. }
1774.
1775. /**
1776. * Get total columns
1777. *
1778. * @return int
1779. */
56. DB::groupBy('post.id');
57. DB::orderBy('post.add_date','DESC');
58. DB::limit(null, 20);
59. $posts = DB::get('post');
60. //output($posts->stringQuery());
61. //$pager = $posts->pagination('category/'.URI::segment(2).'/'.URI::segment(3).'/');
62.
63. $pager = \Pagination::url( 'category/'.URI::segment(2).'/'.URI::segment(3).'/' )
64. ->limit( 20 )
65. ->totalRows( $posts->totalRows(true) )
66. ->create();
67.
68. # HEADER TITLE #
69. $master = 'Perpa Ticaret Merkezi'; //DB::whereId(1)->settingsRowTitle();
70. Masterpage::title($master . ' » '. mb_convert_case($category->name, MB_CASE_TITLE) );
71.
72.
73. View::pageTitle($category->name)
74. ->category($category)
75. ->posts($posts)
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. /**