done #3
@@ -22,6 +22,7 @@ class BancaDati {
 | 
				
			|||||||
                , $this->pw
 | 
					                , $this->pw
 | 
				
			||||||
                , array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
 | 
					                , array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
 | 
				
			||||||
        } catch (PDOException $e) {
 | 
					        } catch (PDOException $e) {
 | 
				
			||||||
 | 
					            var_dump($e);
 | 
				
			||||||
            die;
 | 
					            die;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -108,7 +109,7 @@ class BancaDati {
 | 
				
			|||||||
     * @return void
 | 
					     * @return void
 | 
				
			||||||
     * @author Malte Schulze Hobeling
 | 
					     * @author Malte Schulze Hobeling
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function select(string $table, array $where){
 | 
					    public function select(string $table, array $where = []){
 | 
				
			||||||
        $whereString = "";
 | 
					        $whereString = "";
 | 
				
			||||||
        $orderString = "";
 | 
					        $orderString = "";
 | 
				
			||||||
        if(isset($where["by"])){
 | 
					        if(isset($where["by"])){
 | 
				
			||||||
@@ -125,9 +126,9 @@ class BancaDati {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            $whereString .= "`" . $col . "` LIKE '" . $v . "'";
 | 
					            $whereString .= "`" . $col . "` LIKE '" . $v . "'";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        $sql = "SELECT * FROM ".$table." WHERE ".$whereString.$orderString.";";
 | 
					        $sql = "SELECT * FROM " . $table . ((count($where) > 0) ? " WHERE ".$whereString.$orderString : "") .";";
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            return $this->pdo->query($sql)->fetch();
 | 
					            return $this->pdo->query($sql)->fetchAll();
 | 
				
			||||||
        }catch (PDOException $e){
 | 
					        }catch (PDOException $e){
 | 
				
			||||||
            die;
 | 
					            die;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								User.php
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								User.php
									
									
									
									
									
								
							@@ -18,7 +18,7 @@ class User {
 | 
				
			|||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    public function loginWithUsername(string $username, string $password) : string {
 | 
					    public function loginWithUsername(string $username, string $password) : string {
 | 
				
			||||||
        $userObject = $this->db->select("utente", ["nomeUtente" => $username]);
 | 
					        $userObject = $this->db->select("utente", ["nomeUtente" => $username])[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(!$userObject){
 | 
					        if(!$userObject){
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
@@ -38,7 +38,7 @@ class User {
 | 
				
			|||||||
        return $this->token;
 | 
					        return $this->token;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    public function loginWithToken(string $token){
 | 
					    public function loginWithToken(string $token){
 | 
				
			||||||
        $userObject = $this->db->select("utente", ["gettone" => $token]);
 | 
					        $userObject = $this->db->select("utente", ["gettone" => $token])[0];
 | 
				
			||||||
        if(!$userObject){
 | 
					        if(!$userObject){
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user