Added context class.
This commit is contained in:
parent
811e2ffd1d
commit
f66001a4cf
2 changed files with 24 additions and 1 deletions
|
@ -13,10 +13,11 @@ define('AWK_DIR_SRC', AWK_ROOT . '/src');
|
|||
define('AWK_DIR_LIB', AWK_ROOT . '/lib');
|
||||
define('AWK_DIR_PUB', AWK_ROOT . '/public');
|
||||
define('AWK_DIR_CFG', AWK_ROOT . '/config');
|
||||
define('HAU_DIR_DBM', AWK_ROOT . '/database');
|
||||
|
||||
require_once AWK_DIR_LIB . '/index/index.php';
|
||||
|
||||
//Autoloader::addNamespace(__NAMESPACE__, AWK_DIR_SRC);
|
||||
Autoloader::addNamespace(__NAMESPACE__, AWK_DIR_SRC);
|
||||
Environment::setDebug(AWK_DEBUG);
|
||||
|
||||
$config = parse_ini_file(AWK_DIR_CFG . '/config.ini');
|
||||
|
@ -29,3 +30,5 @@ try {
|
|||
echo '<h3>Unable to connect to database</h3>';
|
||||
die($ex->getMessage());
|
||||
}
|
||||
|
||||
$awk = new AwakiContext($db);
|
||||
|
|
20
src/AwakiContext.php
Normal file
20
src/AwakiContext.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
namespace Awaki;
|
||||
|
||||
use Index\Data\IDbConnection;
|
||||
|
||||
class AwakiContext {
|
||||
private const DB_INIT = 'SET SESSION time_zone = \'+00:00\', sql_mode = \'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\';';
|
||||
|
||||
private IDbConnection $dbConn;
|
||||
|
||||
public function __construct(IDbConnection $dbConn) {
|
||||
$this->dbConn = $dbConn;
|
||||
$dbConn->execute(self::DB_INIT);
|
||||
}
|
||||
|
||||
public function getDbQueryCount(): int {
|
||||
$result = $this->dbConn->query('SHOW SESSION STATUS LIKE "Questions"');
|
||||
return $result->next() ? $result->getInteger(0) : 0;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue