Rad'Val
Rad'Val

Reputation: 9231

How can you run a mysqli query with CodeIgniter?

Does anyone have a clue how to run a mysqli query with CI. I did change the db driver in the config file, but I'm still unable to use multiple queries like

$sql = "SELECT * FROM c WHERE 1;
        DROP TABLE IF EXISTS c;"
$query = $this->db->query($sql);

Anyone has any clue how to do this using only CI, no additional libraries, because theoretically CI supports mysqli.

Thanks

Upvotes: 2

Views: 8824

Answers (3)

sooraj subramanyan
sooraj subramanyan

Reputation: 67

No need for additional libraries in CI if you want to change mysql to mysqli just go to the config->database.php and change to $db['default']['dbdriver'] = 'mysql'; to $db['default']['dbdriver'] = 'mysqli';

Upvotes: 0

Kristopher Windsor
Kristopher Windsor

Reputation: 251

You cannot use CI's Active Records at this time, but you can use mysqli functions with the connection / mysqli instance that CI created. Set your CodeIgniter database driver to mysqli, then call mysqli functions like mysqli_multi_query($this->db->conn_id...

Upvotes: 0

Rad'Val
Rad'Val

Reputation: 9231

At this moment, even if CI supports mysqli, multiple queries are not supported as far as I know.

Upvotes: 3

Related Questions