Nah, saya menemukan bahwa fungsi _execute() di CI_DB_pdo_driver di dalam sistem codeigniter tidak berfungsi dengan baik, mungkin karena versi php. Pokoknya saya mengubah kode CodeIgniter dari:
function _execute($sql)
{
$sql = $this->_prep_query($sql);
$result_id = $this->conn_id->prepare($sql);
$result_id->execute();
if (is_object($result_id))
{
if (is_numeric(stripos($sql, 'SELECT')))
{
$this->affect_rows = count($result_id->fetchAll());
$result_id->execute();
}
else
{
$this->affect_rows = $result_id->rowCount();
}
}
else
{
$this->affect_rows = 0;
}
return $result_id;
}
UNTUK:
function _execute($sql)
{
$sql = $this->_prep_query($sql);
$result_id = $this->conn_id->prepare($sql);
$result_id->execute();
if (is_object($result_id))
{
if (preg_match('/^\s*"?(SELECT)\s+/i', $sql))
{
$this->affect_rows = count($result_id->fetchAll());
$result_id->execute();
}
else
{
$this->affect_rows = $result_id->rowCount();
}
}
else
{
$this->affect_rows = 0;
}
return $result_id;
}
Bagian yang menguji apakah $sql berisi "SELECT" di dalamnya tidak berfungsi, jadi ketika saya mencoba INSERT "$result_id->execute()" dipanggil dua kali.