KarlvonKarton Posted January 18, 2018 Share Posted January 18, 2018 I have a function in a custom class that works. But now I'm trying to connect to an external database, but this gives an error on this line (second version hereunder): $rs->setFetchMode(\PDO::FETCH_ASSOC); I'm a bit stuck... public function getFrontpagePropertiesList(){ $sql = "SELECT * FROM max_properties WHERE (client_var_368='1') ORDER BY max_properties.wijziging_datum DESC "; $rs = wire('database')->prepare($sql); $rs->setFetchMode(\PDO::FETCH_ASSOC); $rs->execute(); return $rs->fetchAll(); } public function getFrontpagePropertiesList(){ $dbm = new Database('localhost', 'user', 'PASS', 'db'); $sql = "SELECT * FROM max_properties WHERE (client_var_368='1') ORDER BY max_properties.wijziging_datum DESC "; $rs = $dbm->prepare($sql); $rs->setFetchMode(\PDO::FETCH_ASSOC); // THIS gives error $rs->execute(); return $rs->fetchAll(); } Link to comment Share on other sites More sharing options...
BitPoet Posted January 19, 2018 Share Posted January 19, 2018 The Database class inherits from mysqli. You want to use WireDatabasePDO instead. 3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now