TekiusFanatikus Posted June 1, 2010 Share Posted June 1, 2010 Fatal error: Call to undefined function getDB() in C:\...\xampp\htdocs\DAL.php on line 10 test.php include 'DAL.php'; $DALClass = new DAL(); if($results = $DALClass->getData()){ ... } DAL.php <?php class DAL { function getDB(){ return $mysqli = new mysqli('localhost','root','','mytest'); } public function getData(){ $db = getDB(); return $result = $db->query("select * from tbl_main"); } } ?> I'm coming from another coding platform and trying to replicate my knowledge in PHP. Link to comment https://forums.phpfreaks.com/topic/203543-internal-class-method-call-undefined/ Share on other sites More sharing options...
teynon Posted June 1, 2010 Share Posted June 1, 2010 $this->getDB(); Link to comment https://forums.phpfreaks.com/topic/203543-internal-class-method-call-undefined/#findComment-1066235 Share on other sites More sharing options...
TekiusFanatikus Posted June 1, 2010 Author Share Posted June 1, 2010 Thanks, this works! I found another solution that had a class extending mysqli for a DAL... I suppose that approach would be better or would my approach be equally as good? Link to comment https://forums.phpfreaks.com/topic/203543-internal-class-method-call-undefined/#findComment-1066334 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.