Hi I'm kinda new to this and I would like to ask someone here that are experts in codeigniter framework and PHP.
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 is an error, report 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:
change:
with:
You should change the content of the file
DB_driver.php
in you codeigniter system directory. Go to:And change the following line:
to :
here is a extraction of the
DB_driver.php
Once you have specified
'mysqli'
, you can use the following function to get mysqli. For example,mysqli_real_escape_str
, etc.:Open the file 'database.php' under the folder '/application/config/'
Move to the line
Modify it as below