add db state
This commit is contained in:
@@ -10,10 +10,12 @@ class Db extends PhpObject
|
|||||||
const DB_PEACHY = 'NO_ERR';
|
const DB_PEACHY = 'NO_ERR';
|
||||||
const DB_NO_CONN = 'ERR_1';
|
const DB_NO_CONN = 'ERR_1';
|
||||||
const DB_NO_DATA = 'ERR_2';
|
const DB_NO_DATA = 'ERR_2';
|
||||||
|
const DB_NO_TABLE = 'ERR_3';
|
||||||
const ID_TAG = 'id_';
|
const ID_TAG = 'id_';
|
||||||
|
|
||||||
//Database formats
|
//Database formats
|
||||||
const MONTH_FORMAT = 'Ym';
|
const MONTH_FORMAT = 'Ym';
|
||||||
|
const DATE_FORMAT = 'Y-m-d';
|
||||||
const TIMESTAMP_FORMAT = 'Y-m-d H:i:s';
|
const TIMESTAMP_FORMAT = 'Y-m-d H:i:s';
|
||||||
|
|
||||||
public $sDbState;
|
public $sDbState;
|
||||||
@@ -63,6 +65,10 @@ class Db extends PhpObject
|
|||||||
$this->addError('Could not find database "'.$this->sDatabase.'"');
|
$this->addError('Could not find database "'.$this->sDatabase.'"');
|
||||||
$this->sDbState = self::DB_NO_DATA;
|
$this->sDbState = self::DB_NO_DATA;
|
||||||
}
|
}
|
||||||
|
elseif(empty($this->getArrayQuery("SHOW TABLES")))
|
||||||
|
{
|
||||||
|
$this->sDbState = self::DB_NO_TABLE;
|
||||||
|
}
|
||||||
else $this->sDbState = self::DB_PEACHY;
|
else $this->sDbState = self::DB_PEACHY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -360,7 +366,6 @@ class Db extends PhpObject
|
|||||||
|
|
||||||
//Cleaning values
|
//Cleaning values
|
||||||
$this->cleanSql($sTableName);
|
$this->cleanSql($sTableName);
|
||||||
$this->cleanSql($iTableId);
|
|
||||||
$this->cleanSql($asData);
|
$this->cleanSql($asData);
|
||||||
$this->cleanSql($asConstraints);
|
$this->cleanSql($asConstraints);
|
||||||
$asQueryValues = $this->addQuotes($asData);
|
$asQueryValues = $this->addQuotes($asData);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ abstract class Main extends PhpObject
|
|||||||
//$this->setLanguage($sLang);
|
//$this->setLanguage($sLang);
|
||||||
//$this->oTranslator = new Translator($this->getLanguage());
|
//$this->oTranslator = new Translator($this->getLanguage());
|
||||||
$this->oDb = new Db(Settings::DB_SERVER, Settings::DB_LOGIN, Settings::DB_PASS, Settings::DB_NAME, $this->getSqlOptions() , Settings::DB_ENC);
|
$this->oDb = new Db(Settings::DB_SERVER, Settings::DB_LOGIN, Settings::DB_PASS, Settings::DB_NAME, $this->getSqlOptions() , Settings::DB_ENC);
|
||||||
if($this->oDb->sDbState == Db::DB_NO_DATA) $this->install();
|
if(in_array($this->oDb->sDbState, array(Db::DB_NO_DATA, Db::DB_NO_TABLE))) $this->install();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract function install();
|
protected abstract function install();
|
||||||
|
|||||||
@@ -64,10 +64,10 @@ elseif($sAction!='' && !$bLoggedIn)
|
|||||||
$sResult = $oCvTheque->apifunction();
|
$sResult = $oCvTheque->apifunction();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$sResult = CvTheque::getJsonResult(false, Main::NOT_FOUND);
|
$sResult = Main::getJsonResult(false, Main::NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else $sResult = CvTheque::getJsonResult(false, Main::UNAUTHORIZED);
|
else $sResult = Main::getJsonResult(false, Main::UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
elseif($bLoggedIn) $sResult = $oMain->getMainPage();
|
elseif($bLoggedIn) $sResult = $oMain->getMainPage();
|
||||||
else $sResult = $oMain->getLogonPage();
|
else $sResult = $oMain->getLogonPage();
|
||||||
|
|||||||
Reference in New Issue
Block a user