/** * @return boolean */ public function login($table) { $hash = $this->get_user_hash(); $sql = "select * from {$table} where username='******' and password_hash='{$hash}';"; $database = new Database('localhost', 'pdo_ret', 'root', ''); if (gettype($database->get_db()) != 'int') { $result = $database->query($sql); $result = count($result); if ($result > 0) { return TRUE; } else { return FALSE; } return TRUE; } else { return FALSE; } }
public function exists_table(array $check_array) { $this->db = Database::get_db(); $query = "SELECT COUNT(*) FROM {$check_array['rule_value']} WHERE {$check_array['item']} LIKE :inp_value"; $prep = $this->db->conn->prepare($query); $params = array(':inp_value' => $check_array['inp_value']); if ($prep->execute($params)) { $result = $prep->fetchColumn(); } else { die("Class In database error"); } if ($result < 1) { $er = "Wrong {$check_array['item']}."; $this->add_error($er); } return; }
public function __construct() { $this->db = Database::get_db(); // or $this->db = Database::get_db('configuration_array_name_here'); }