fixed using correct credentials
This commit is contained in:
@@ -10,16 +10,23 @@ class TTCrudBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
public static function getFullyQualifiedTable(): string {
|
||||
private static function getFullyQualifiedTable(): string {
|
||||
$table = str_replace('Model', '', get_called_class());
|
||||
$tableIncludesADBSuffix = strpos($table, 'ADB') !== false;
|
||||
$table = str_replace('ADB', '', $table);
|
||||
return "`" . ($tableIncludesADBSuffix ? ADDRESSDB_DBNAME : FRONKDB_DBNAME) . "`.`" . $table . "`";
|
||||
}
|
||||
|
||||
private static function getDB() {
|
||||
if (strpos(self::getFullyQualifiedTable(), ADDRESSDB_DBNAME) !== false)
|
||||
$FronkDB = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
else $FronkDB = FronkDB::singleton();
|
||||
|
||||
return $FronkDB->link;
|
||||
}
|
||||
|
||||
public static function create($data) {
|
||||
$FronkDB = FronkDB::singleton();
|
||||
$db = $FronkDB->link;
|
||||
$db = self::getDB();
|
||||
$table = self::getFullyQualifiedTable();
|
||||
self::checkAllFields($data, ['id']);
|
||||
|
||||
@@ -90,8 +97,7 @@ class TTCrudBaseModel {
|
||||
|
||||
|
||||
public static function get($id): TTCrudBaseModel {
|
||||
$FronkDB = FronkDB::singleton();
|
||||
$db = $FronkDB->link;
|
||||
$db = self::getDB();
|
||||
$id = $db->real_escape_string($id);
|
||||
$table = self::getFullyQualifiedTable();
|
||||
$sql = "SELECT * FROM $table WHERE `id` = $id";
|
||||
@@ -103,8 +109,7 @@ class TTCrudBaseModel {
|
||||
}
|
||||
|
||||
public static function count($filter = []): int {
|
||||
$FronkDB = FronkDB::singleton();
|
||||
$db = $FronkDB->link;
|
||||
$db = self::getDB();
|
||||
$table = self::getFullyQualifiedTable();
|
||||
$filter = self::getSQLFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as count FROM $table $filter";
|
||||
@@ -131,8 +136,7 @@ class TTCrudBaseModel {
|
||||
}
|
||||
|
||||
public static function getAll($filter = [], $limit = null, $offset = 0, $order = ["key" => null]): array {
|
||||
$FronkDB = FronkDB::singleton();
|
||||
$db = $FronkDB->link;
|
||||
$db = self::getDB();
|
||||
$table = self::getFullyQualifiedTable();
|
||||
$filter = self::getSQLFilter($filter);
|
||||
$sql = "SELECT * FROM $table $filter";
|
||||
@@ -156,8 +160,7 @@ class TTCrudBaseModel {
|
||||
}
|
||||
|
||||
public static function update($data) {
|
||||
$FronkDB = FronkDB::singleton();
|
||||
$db = $FronkDB->link;
|
||||
$db = self::getDB();
|
||||
$table = self::getFullyQualifiedTable();
|
||||
|
||||
// Check if all fields are set
|
||||
@@ -192,8 +195,7 @@ class TTCrudBaseModel {
|
||||
}
|
||||
|
||||
public static function delete($id) {
|
||||
$FronkDB = FronkDB::singleton();
|
||||
$db = $FronkDB->link;
|
||||
$db = self::getDB();
|
||||
$table = self::getFullyQualifiedTable();
|
||||
$id = $db->real_escape_string($id);
|
||||
$sql = "DELETE FROM $table WHERE `id` = $id";
|
||||
|
||||
Reference in New Issue
Block a user