Setup Database and check connection |
I have my first attempt(i never used a framework) to use CodeIgniter 4.
What I try to achieve is to setup database in CodeIgniter and check in controller if it works. For database I use MySQL Community Server 8.0.19: https://dev.mysql.com/downloads/mysql/ This is the controller: Code: class Testdb extends BaseController{ And this is Database.php: Code: public $default = [ When I check in browser I get this error: `mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, object given`. I test the connection for db with MySQL Workbench and everything works fine. What I do wrong and how to fix it?
Hi the problem here are that you are using CodeIgniters built in Query Builder, and then trying to access the data with mysqli built in functions. You need to stick to CodeIgniters own function or switch over completely to mysqli_ functions.
Here are how you are supposed to fecth data: https://codeigniter4.github.io/userguide...sults.html PS. Moved your thread into CI 4 Support.
I changed `var_dump(...)` with `var_dump($sel->getRow(0)->one);` and now it works.
Thank you. I thought I can combine CI4 with mysqli |
Welcome Guest, Not a member yet? Register Sign In |