CodeIgniter のデータベース カスタム関数呼び出しの使用:
application/config/database.phpにmysqliが設定されていると仮定します。
$db['default']['dbdriver'] = 'mysqli';
次に、モデルで:
$this->load->database();
// Perform a mysqli_multi_query
$db_id = $this->db->conn_id;
$this->db->call_function("multi_query", $db_id, "SET @rownum:=0; SELECT @rownum:=@rownum+1 as count, student_name,student_info FROM student;"
$this->db->call_function('next_result', $db_id); // Skip the first query in this multi_query since you want the result from the second query
$result = $this->db->call_function("store_result", $db_id);
// Output each row
while($row = $result->fetch_assoc()){
$row['count'] . " ". $row['student_name'] . " " . $row['student_info'] . "\n";
}