if ( ! function_exists('db_next_result')) { /* * Replaces the CI_DB_mysqli_result::next_result() method that the old * CodeIgniter 2 core was patched with. A stored procedure CALL returns * an extra (status) result set, which must be drained before the next * query or MySQL reports "Commands out of sync". */ function db_next_result($db) { if ( ! is_object($db) || ! ($db->conn_id instanceof mysqli)) { return FALSE; } while (mysqli_more_results($db->conn_id) && mysqli_next_result($db->conn_id)) { if ($result = mysqli_store_result($db->conn_id)) { mysqli_free_result($result); } } return TRUE; } }