How can I use mysqli drivers in PHP native query?
For example. My code:
Model
class Home_model extends CI_Model{
public function getusers(){
$q = "SELECT * FROM `users`";
return $r = mysqli_query($q);
}
}
Controller:
class Home extends CI_Controller{
public function iterateuser(){
while($row = mysqli_fetch_object($this->Home_model->getusers())) {
echo $row->username;
}
}
My code above has an error, saying:
mysqli_query expects at least 2 parameters
Is there a way in CodeIgniter to pass the link on the mysqli_query()
first parameter as described on the php.net documentation http://php.net/manual/en/mysqli.query.php
go to:
yourproject/application/config/database.php
change:
$db['default']['dbdriver'] = 'mysql';
with:
$db['default']['dbdriver'] = 'mysqli';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With