I have a dbfunctions class that has the functions to retrieve and write data to database. However, the retrieval doesn't work and I can't understand why it doesn't work.
The read functions looks like this:
public function haeParametreittaTietokannasta($f_sql) { try { $this->sql_lause = $this->db->prepare($f_sql); $this->haku = $this->sql_lause->execute(); } catch (PDOException $ex) { die("Tapahtui virhe tietoja noudettaessa : " . $ex->getMessage()); } if(!$this->haku) { $this->tulos = $this->haku->fetchAll(); return $this->tulos; } else { return false; } } // END FUNCTION And this is how I call the function:
$countries = $dabase->haeParametreittaTietokannasta("SELECT * FROM countries"); The query always returns false, and I've tried showing error info and it says: array ( 0 => '00000', 1 => NULL, 2 => NULL, ) (And yes, I have created a new object in the main code.)
I've just started to learn PHP and there might be a simple error I just can't see...