/** * Tests the __construct method. * * @return void * * @covers Joomla\Model\AbstractModel::__construct * @since 1.0 */ public function test__construct() { $this->assertEquals(new Registry(), $this->instance->getState(), 'Checks default state.'); $dbMock = $this->getMockBuilder('Joomla\\Database\\DatabaseDriver')->disableOriginalConstructor()->getMockForAbstractClass(); $state = new Registry(array('foo' => 'bar')); $class = new DatabaseModel($dbMock, $state); $this->assertEquals($state, $class->getState(), 'Checks state injection.'); }
public function getserialAction() { $fc = FrontController::getInstance(); $data = new DatabaseModel(); $params = $fc->getParams(); $name = sqlite_escape_string(strip_tags(trim($params['plname']))); $data->getSerialData($name); $out = $data->showModalTable(); $fc->setBody($out); }
function select_test($table, $data, $condition) { include '../helpers/QueryGenrator.php'; $QueryGen = new QueryGenrator(); include '../Models/Database.php'; $DB = new DatabaseModel(); $Query = $QueryGen->select($table, $data, $condition); $DBEntry = $DB->select($Query); print_r($DBEntry); }
/** * Created by PhpStorm. * User: root * Date: 21/11/15 * Time: 5:42 PM */ function AddUser($Data) { $table = 'userinfo'; include '../common/Models/Database.php'; include '../common/helpers/QueryGenrator.php'; $QueryGen = new QueryGenrator(); $DB = new DatabaseModel(); $Query = $QueryGen->insert($table, $Data); $DBEntry = $DB->insert($Query); return $DBEntry; }
/** * Created by PhpStorm. * User: sp * Date: 25/11/15 * Time: 3:56 PM */ function GetUsername($Data) { $table = 'userinfo'; require_once '../common/Models/Database.php'; require_once '../common/helpers/QueryGenrator.php'; $QueryGen = new QueryGenrator(); $DB = new DatabaseModel(); $Username = $Data['Username']; $Query = $QueryGen->select($table, $Data = "None", $Condition = "WHERE `Username` = '{$Username}'"); $DBEntry = $DB->select($Query); return $DBEntry; }
/** * Created by PhpStorm. * User: root * Date: 21/11/15 * Time: 5:42 PM */ function GetUser($Data) { $table = 'userinfo'; include '../common/Models/Database.php'; include '../common/helpers/QueryGenrator.php'; $QueryGen = new QueryGenrator(); $DB = new DatabaseModel(); $Token = $Data['Token']; $Query = $QueryGen->select($table, $Data = "None", $Condition = "WHERE `AccessToken` = '{$Token}'"); $DBEntry = $DB->select($Query); return $DBEntry; }
/** * Created by PhpStorm. * User: root * Date: 21/11/15 * Time: 5:42 PM */ function AddFile($Data) { $table = 'codes'; require_once '../common/Models/Database.php'; require_once '../common/helpers/QueryGenrator.php'; $QueryGen = new QueryGenrator(); $DB = new DatabaseModel(); $Query = $QueryGen->insert($table, $Data); $DBEntry = $DB->insert($Query); if ($DBEntry == 200) { return 201; } return $DBEntry; }
/** * Created by PhpStorm. * User: sp * Date: 25/11/15 * Time: 2:04 PM */ function RenameFile($Data) { require_once '../common/Models/Database.php'; require_once '../common/helpers/QueryGenrator.php'; $table = 'codes'; $QueryGen = new QueryGenrator(); $DB = new DatabaseModel(); $File = $Data['File']; $Username = $Data['Username']; $Filename = $Data['Filename']; $data = array("Filename" => $Filename); $Query = $QueryGen->update($table, $data, $condition = $Condition = "WHERE `Username` = '{$Username}' AND `File` = '{$File}'"); $DBEntry = $DB->update($Query); return $DBEntry; }
public function __construct($input = null) { parent::__construct($input); if ($this->role === null) { $this->role = 'admin'; } }
function __construct($input = null) { parent::__construct($input); if ($this->role === null) { $this->role = 'user'; } }
public static function getInstance() { if (self::$instance === false) { self::$instance = new DatabaseModel(); } return self::$instance; }
/** * Created by PhpStorm. * User: root * Date: 21/11/15 * Time: 5:42 PM */ function AddToken($Data) { include '../common/Models/Database.php'; include '../common/helpers/QueryGenrator.php'; $table = 'userinfo'; $QueryGen = new QueryGenrator(); $DB = new DatabaseModel(); $data = array("AccessToken" => getGUID()); $Email = $Data['Email']; $Password = $Data['Password']; $condition = "WHERE Email = '{$Email}' AND Password = '******'"; $QueryCheck = $Query = $QueryGen->select($table, $DATA = "None", $condition); $CheckInfo = $DB->select($QueryCheck); if ($CheckInfo == ERROR_DATA_NOT_FOUND) { return ERROR_DATA_NOT_FOUND; } $Query = $QueryGen->update($table, $data, $condition); $DBEntry = $DB->update($Query); return $data['AccessToken']; }
/** * Created by PhpStorm. * User: root * Date: 21/11/15 * Time: 5:42 PM */ function GetFile($Username) { $table = 'codes'; require_once '../common/Models/Database.php'; require_once '../common/helpers/QueryGenrator.php'; $QueryGen = new QueryGenrator(); $DB = new DatabaseModel(); $Query = $QueryGen->select($table, $Data = "None", $Condition = "WHERE `Username` = '{$Username}'"); $GetResponse = $DB->select($Query); if ($GetResponse != 903) { $Response["STATUS"] = "True"; $Response["STATUS CODE"] = 200; $Response['Payloads'] = $GetResponse; } else { $Response["STATUS"] = "True"; $Response["STATUS CODE"] = 903; $Response["Message"] = "No Data Found"; } return $Response; }
public function __construct() { @session_start(); self::$db = \DatabaseModel::getInstance(); $this->post_data = filter_input_array(INPUT_POST); if ($this->post_data) { $this->csrfCheck(); $this->post_data = $this->validateInput($this->post_data); } $get_data = filter_input_array(INPUT_GET); if ($get_data) { $get_data = $this->validateInput(); } }
/** * Constructor of this class. Used for creating a new DB connection and to set PDO modes. * @param \PDO The PDO object */ public function __construct() { $args = func_get_args(); //get all arguments to this function if (isset($args[0]) && get_class($args[0]) === "PDO") { //If only one argument is present and if that argument is a PDO object and is directly passed in the argument, then do not create a new PDO object. Just use the old object $this->dbh = $args[0]; } else { $dbConfig = new DatabaseConfig('pdo_sqlite', NULL, NULL, NULL); //get a new DB connection parent::__construct($dbConfig); //call the DatabaseModel's constructor to pass the DatabaseConfig object to initialize a new object $this->dbh = new \PDO("sqlite::memory:"); //create a new PDO object } $this->dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); //set PDO attributes }
/** * metoda pro zjisteni, zda prihlasovany uzivatel ma pravo na vstup do admina * @param array $credentials vyplnene udaje v prihlasovacim formulari */ public function authenticate(array $credentials) { self::$db = \DatabaseModel::getInstance(); $username = $credentials['username']; $password = $credentials['password']; $row = self::$db->getUser($username); if ($row) { $password_is_correct = password_verify($password, $row['password']); if ($password_is_correct !== true) { throw new Exception('Špatně zadané heslo'); } else { $_SESSION['username'] = $row['username']; $_SESSION['rights'] = $row['rights_level']; } } else { throw new Exception('Špatně zadané jméno'); } }
public function __construct() { @session_start(); self::$db = \DatabaseModel::getInstance(); $this->user = new \User(); $is_logged_in = $this->user->isLoggedIn(); if ($is_logged_in === false) { $this->redirect('/admin/prihlaseni/login'); } $this->post_data = filter_input_array(INPUT_POST); if ($this->post_data) { $csrfCheck = $this->csrfCheck(); if ($csrfCheck === false) { $this->info = $_SESSION['info'] = "Akce se nepovedla, prosím obnovte stránku a zkuste to znovu."; $this->redirect('/admin/'); } $this->post_data = $this->validateInput($this->post_data); } }
/** * Constructor of this class. Used for creating a new DB connection and to set PDO modes. * @param db_name The name of the DB * @param db_user The username of the DB for connection * @param db_pass The password of the DB for connection */ public function __construct() { $args = func_get_args(); //get all arguments to this function if (!isset($args[0])) { //If no arguments are set, then return false return false; } if (count($args) > 1) { $dbConfig = new DatabaseConfig('pdo_mysql', $args[0], $args[1], $args[2]); //get a new DB configuration parent::__construct($dbConfig); //call the DatabaseModel's constructor to pass the DatabaseConfig object to initialize a new object $this->dbh = new \PDO("mysql:dbname={$dbConfig->dbname};host={$dbConfig->host};", $dbConfig->username, $dbConfig->password); //create a new PDO object } elseif (get_class($args[0]) === "PDO") { //If only one argument is present and if that argument is a PDO object and is directly passed in the argument, then do not create a new PDO object. Just use the old object $this->dbh = $args[0]; } $this->dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); //set PDO attributes }
public function __construct() { parent::__construct(); }
/** * Write a wrapper function that * 1. Adds users * 2. Adds database * 3. Creates association between users and database using existing models * Added more checks 14/09/2015 . Must be rewritten if there is time. */ function addUser() { $request = Slim::getInstance()->request(); $user = json_decode($request->getBody()); $AppModel = new Model(); $Utente = new UtenteModel(); $Uform = new UtenteForm(); $Dbase = new DatabaseModel(); $Dform = new DatabaseForm(); $Assoc = new AssociazioneModel(); $Aform = new AssociazioneForm(); //Utente $Uform->email = trim_string($user->email); $Uform->id_utente = null; $pwd = Password::randomPassword(); $Uform->passwd = Password::hashPassword($pwd); //Database $piva = (string) trim_string($user->piva); $Dform->nome = INIDB_WKI . "{$piva}"; $Dform->alias = !empty($user->ragsoc) ? $user->ragsoc : $user->piva; $Dform->codice = $user->piva; //$Dform->id_database = $AppModel->getIdDb($Dform->nome); $Dform->id_database = $AppModel->getIdDbbyCodice($Dform->codice); $id_utente = $AppModel->getIdUtente($Uform->email); if (!empty($user->email) && !empty($user->piva)) { try { if (empty($id_utente)) { ///////////////////////////// User doesn't exist, save user and send and email with password////////////////////////////////////////////////// if ($Utente->saveDb($Uform, 1, 1)) { $testo = "<p>Salve {$user->email},</p>\r\n <p>i tuoi dati di accesso presso <b>" . NAME . ":</b><br><br>\r\n <b>Nome utente</b>: {$user->email}<br>\r\n <b>Password:</b> {$pwd}</p>\r\n <p>Una volta effettuato l'accesso ti verrà richiesto di cambiare la password tramite l'apposita funzionalità</p>\r\n <p>Adesso puoi effettuare il login al seguente indirizzo: <a href=\"" . URL . "index.php?section=login\">" . URL . "index.php?section=login</a></p>"; Mailer::sendMail($user->email, NAME, EMAIL, false, NAME . ' - Utente e password', $testo); } ///////////////////////////// If database exist already, then create association of user and database and date of expiry////////////////////////// if (!empty($Dform->id_database)) { $Aform->id_utente = $AppModel->getIdUtente($user->email); $Aform->id_database = $AppModel->getIdDbbyCodice($Dform->codice); $Aform->data_scadenza = (string) $user->data_scadenza; $Assoc->saveDb($Aform, 1, 1); } else { //////////////////////////// If database does not exist , create datbase and associate it with the user /////////////////////////////////////////// $Dbase->saveDb($Dform); if (!file_exists(PATH_BASE . DS . CSV . DS . $Dform->codice) && !is_dir(PATH_BASE . DS . CSV . DS . $Dform->codice)) { mkdir(PATH_BASE . DS . CSV . DS . $Dform->codice, 0777, true); } $Aform->id_utente = $AppModel->getIdUtente($user->email); $Aform->id_database = $AppModel->getIdDbbyCodice($Dform->codice); $Aform->data_scadenza = (string) $user->data_scadenza; $Assoc->saveDb($Aform, 1, 1); } ////////////////////////// If request is for complete application(f-light), launch this procedure to modify application //////////////////////////////////// if ($user->tipo_gest == '1') { $Dbase->setAuth($AppModel->getIdDbbyCodice($Dform->codice), 3, 1); $Dbase->ImpostazioneFlight($Dform->nome); // maintain name as in name of Database } //////////////////////// If all this is done we are sure that a user, database and their association has been succefully done so throw out json /////////// $status = array("statuscode" => 200, "response" => array("success" => true, "msg" => "E stato creato un utente, database e un abbinamento/associazione.", "data" => array())); echo json_encode($status); } else { //////////////////////// We arrived here because user id was found, so we send a message to the user saying we added a database/company to them and they can use old password////// $testo = "<p>Salve {$user->email},</p>\r\n <p>La sua richiesta è stata accettata. Abbiamo abbinato una nuova basi di dati a questo utente.</p>\r\n <p>i tuoi dati di accesso presso <b>" . NAME . ":</b><br>\r\n <p>Si potrebbe usare le tue credenziali già esistente per accedere.</p>\r\n <p></p>\r\n <p>Adesso puoi effettuare il login al seguente indirizzo: <a href=\"" . URL . "index.php?section=login\">" . URL . "index.php?section=login</a></p>"; $Aform->id_utente = $AppModel->getIdUtente($user->email); $Aform->id_database = $AppModel->getIdDbbyCodice($Dform->codice); $Aform->data_scadenza = (string) $user->data_scadenza; $Dform->id_database = $AppModel->getIdDbbyCodice($Dform->codice); ///////////////////////// If a database already exist, we send and email and create and create and association with the user /////////////////////////////////////////////////// if (!empty($Dform->id_database)) { Mailer::sendMail($user->email, NAME, EMAIL, false, NAME . ' - Utente e password', $testo); if (!$Assoc->controllaUnicita($Aform->id_utente, $Aform->id_database, $Aform->id_associazione)) { $Assoc->saveDb($Aform, 1, 1); $status = array("statuscode" => 200, "response" => array("success" => true, "msg" => "Un abbinamento/associazione è stato creato.", "data" => array())); echo json_encode($status); } else { $status = array("statuscode" => 200, "response" => array("success" => true, "msg" => "Operazione eseguito con succeso, esiste già un associazione", "data" => array())); echo json_encode($status); } ///////////////////////////// If there is no database, then we create database , send email and create folder and association//////////// } else { $Dform->id_database = $AppModel->getIdDbbyCodice($Dform->codice); $Dbase->saveDb($Dform); Mailer::sendMail($user->email, NAME, EMAIL, false, NAME . ' - Utente e password', $testo); if (!file_exists(PATH_BASE . DS . CSV . DS . $Dform->codice) && !is_dir(PATH_BASE . DS . CSV . DS . $Dform->codice)) { mkdir(PATH_BASE . DS . CSV . DS . $Dform->codice, 0777, true); } $Assoc->saveDb($Aform, 1, 1); $status = array("statuscode" => 200, "response" => array("success" => true, "msg" => "E stato creato un database e un abbinamento/associazione. ", "data" => array($Dform->id_database))); echo json_encode($status); } } } catch (Exception $e) { // TODO: What to return $status = array("statuscode" => 200, "response" => array("success" => false, "msg" => "Errori nel inserimento su database o nella creazione della cartella !", "errmsg" => $e->getMessage(), "data" => null)); echo json_encode($status); } } else { $status = array("statuscode" => 200, "response" => array("success" => false, "msg" => "I campi email e partita IVA non possono essere vuoti", "data" => null)); echo json_encode($status); } }
/** * Tests the setDb method. * * @return void * * @since 12.1 */ public function testSetDb() { $db = TestMockDatabaseDriver::create($this); $this->_instance->setDb($db); $this->assertAttributeSame($db, 'db', $this->_instance); }
public function __construct() { self::$db = \DatabaseModel::getInstance(); }
function addUserFromCommerce() { $AppModel = new Model(); $Utente = new UtenteModel(); $Uform = new UtenteForm(); $Dbase = new DatabaseModel(); $Dform = new DatabaseForm(); $Assoc = new AssociazioneModel(); $Aform = new AssociazioneForm(); $request = Slim::getInstance()->request(); $user = json_decode($request->getBody()); //Utente $Uform->email = trim_string($user->email); $Uform->id_utente = null; $pwd = Password::randomPassword(); $Uform->passwd = Password::hashPassword($pwd); $Uform->nome = $user->nome; $numdb = (int) $user->num_db; //TODO: Check for empty number of databases $id_utente = $AppModel->getIdUtente($Uform->email); $piva = trim_string($user->piva); $dbprogr = $AppModel->getNumDB($user->email); $INI = $dbprogr; $FIN = $dbprogr + $numdb; /////////////////////////////////////////////////////////////////////////check if fields are not empty/////////////////////////////// if (!empty($user->email) && !empty($user->piva) && !empty($user->num_db)) { try { ///////////////////////////////////////////////////checks if user exist already or no /////////////////////////////////////// if (empty($id_utente)) { $Utente->saveDb($Uform, 1, 1); $testo = "<p>Salve {$user->email},</p>\r\n <p>i tuoi dati di accesso presso <b>" . NAME . ":</b><br><br>\r\n <b>Nome utente</b>: {$user->email}<br>\r\n <b>Password:</b> {$pwd}</p>\r\n <p>Una volta effettuato l'accesso ti verrà richiesto di cambiare la password tramite l'apposita funzionalità</p>\r\n <p>Adesso puoi effettuare il login al seguente indirizzo: <a href=\"" . URL . "index.php?section=login\">" . URL . "index.php?section=login</a></p>"; Mailer::sendMail($user->email, NAME, EMAIL, false, NAME . ' - Utente e password', $testo); //////////////////////////////////////////////////////////////creates number of databases rquested///////////////////////////////////////////////// $Dform->alias = (string) $user->ragsoc; $dbnames = createDBName($INI, $FIN, $piva); foreach ($dbnames as $key => $value) { $id_database = $AppModel->getIdDb($value); if (empty($id_database)) { $Dform->nome = $value; $Dform->codice = explode("_", $value)[1]; if (!$Dbase->esisteDatabase($Dform->nome)) { $Dbase->saveDb($Dform); if (!file_exists(PATH_BASE . DS . CSV . DS . $Dform->codice) && !is_dir(PATH_BASE . DS . CSV . DS . $Dform->codice)) { mkdir(PATH_BASE . DS . CSV . DS . $Dform->codice, 0777, true); } } } $Aform->id_utente = $AppModel->getIdUtente($user->email); $Aform->id_database = $AppModel->getIdDb($Dform->nome); // use name inserted into db ...not something else $Aform->id_associazione = $Assoc->getIDAssociazione($Aform->id_database, $Aform->id_utente); $Aform->data_scadenza = (string) $user->data_scadenza; if (!$Assoc->controllaUnicita($Aform->id_utente, $Aform->id_database, $Aform->id_associazione)) { $Assoc->saveDb($Aform, 1, 1); } // Check if flight is set, enable menu and impose other conditions. if ($user->tipo_gest == '1') { $Dbase->setAuth($AppModel->getIdDb($Dform->nome), 3, 1); $Dbase->ImpostazioneFlight($Dform->nome); } } //check for errors $AppModel->updateNumDB($Uform->email, $numdb); // TODO: Use error checks to send different jsons that is 1 .error in utente, 2. error in database 3.associazione $status = array("statuscode" => 200, "response" => array("success" => true, "msg" => "Richiesta eseguita con successo. E stato creato un utente, un database e un abbinamento/associazione.", "data" => array())); echo json_encode($status); } else { // if user doesn't exist // 3. send email //2. create db, //create assocciazione with all $Dform->alias = (string) $user->ragsoc; $dbnames = createDBName($INI, $FIN, $piva); foreach ($dbnames as $key => $value) { $id_database = $AppModel->getIdDb($value); if (empty($id_database)) { $Dform->nome = $value; $Dform->codice = explode("_", $value)[1]; if (!$Dbase->esisteDatabase($Dform->nome)) { $Dbase->saveDb($Dform); if (!file_exists(PATH_BASE . DS . CSV . DS . $Dform->codice) && !is_dir(PATH_BASE . DS . CSV . DS . $Dform->codice)) { mkdir(PATH_BASE . DS . CSV . DS . $Dform->codice, 0777, true); } } // else check for errors } //$checkdbname = $Dbase->getDatabase($id_database); // check if database exist already // if so try create associasion //else create db and create association $Aform->id_utente = $AppModel->getIdUtente($user->email); $Aform->id_database = $AppModel->getIdDb($Dform->nome); // use name inserted into db ...not something else $Aform->id_associazione = $Assoc->getIDAssociazione($Aform->id_database, $Aform->id_utente); $Aform->data_scadenza = (string) $user->data_scadenza; if (!$Assoc->controllaUnicita($Aform->id_utente, $Aform->id_database, $Aform->id_associazione)) { $Assoc->saveDb($Aform, 1, 1); } // user alreadey exist send check if database exist and check if associzoine exist then send email $testo = "<p>Salve {$user->email},</p>\r\n <p>La sua richiesta è stata accettata. Abbiamo abbinato una nuova basi di dati a questo utente.</p>\r\n <p>i tuoi dati di accesso presso <b>" . NAME . ":</b><br>\r\n <p>Si potrebbe usare le tue credenziali già esistente per accedere.</p>\r\n <p></p>\r\n <p>Adesso puoi effettuare il login al seguente indirizzo: <a href=\"" . URL . "index.php?section=login\">" . URL . "index.php?section=login</a></p>"; Mailer::sendMail($user->email, NAME, EMAIL, false, NAME . ' - Utente e password', $testo); // Check if flight is set, enable menu and impose other conditions. if ($user->tipo_gest == '1') { $Dbase->setAuth($AppModel->getIdDb($Dform->nome), 3, 1); $Dbase->ImpostazioneFlight($Dform->nome); } } // for each $AppModel->updateNumDB($Uform->email, $numdb); // TODO: Use error checks to send different jsons that is 1 .error in utente, 2. error in database 3.associazione $status = array("statuscode" => 200, "response" => array("success" => true, "msg" => "Richiesta eseguita con successo.E stato creato un database e un abbinamento/associazione. ", "data" => array())); echo json_encode($status); } // else } catch (Exception $e) { $status = array("statuscode" => 200, "response" => array("success" => false, "msg" => "Iscrizione negato, email/utente già esistente!", "errmsg" => $e->getMessage(), "data" => null)); echo json_encode($status); } } else { $status = array("statuscode" => 200, "response" => array("success" => false, "msg" => "I campi email, numero di database e partita IVA non possono essere vuoti", "data" => null)); echo json_encode($status); } }
define("DIR_MODEL", DIR_CONTENT . 'model/'); define("DIR_ENTITY", DIR_CONTENT . 'entity/'); define("DIR_LIBRARY", DIR_CONTENT . 'library/'); define("DIR_TEMP", DIR_ARCHIVE . 'temp/'); define("DIR_UPLOAD", DIR_ARCHIVE . 'upload/'); define("DIR_REGEXP", DIR_ARCHIVE . 'regexp/'); define("TPL_INDEX", 'siteIndex.tpl'); define("TPL_USER_SIGNUP", 'userSignUp.tpl'); define("TPL_USER_SIGNIN", 'userSignIn.tpl'); define("TPL_FILE_UPLOAD", 'fileUpload.tpl'); define("TPL_FILE_LIST", 'fileList.tpl'); define("TPL_INC_FOOTER", 'inc/footer.tpl'); define("TPL_INC_HEADER", 'inc/header.tpl'); define("TPL_INC_LOGO", 'inc/logo.tpl'); define("TPL_INC_MENU_CONNECTED", 'inc/menuConnected.tpl'); define("TPL_INC_MENU_UNCONNECTED", 'inc/menuUnconnected.tpl'); define("MDL_SUFFIX", 'Model.php'); define("MDL_AUTHENTICATE", DIR_MODEL . 'Session' . MDL_SUFFIX); //INIT BDD require_once DIR_MODEL . "\\DatabaseModel.php"; require_once DIR_LIBRARY . '\\medoo.min.php'; require_once DIR_LIBRARY . '\\Dumpmysqldatabase.php'; $host = 'localhost'; $user = '******'; $password = ''; $database_name = 'vawt'; $databaseModel = new DatabaseModel(); $database = $databaseModel->getDatabase(); //INIT TEMPLATE SYS require_once DIR_LIBRARY . '\\template.php'; $extentionValide = array('zip', 'php');
public function load($id) { parent::load($id); unset($this->password); return $this; }
private function unique($field, $value, $satisfier) { $sql = "SELECT * FROM {$satisfier} WHERE {$field} = ?"; return !DatabaseModel::read($sql, PDO::FETCH_ASSOC, null, [$field]) ? true : false; }