I have a CodeIgniter application and SQL Server database. I'm using PDO as a driver, everything works fine, but not when I'm trying to save data that contains the words "select" or "selection".
Example:
$data = array();
$data[] = array('title' => 'all you neeed', 'description' => 'description here');
$data[] = array('title' => 'try this selection', 'description' => 'description here');
$this->db->insert_batch($this->table, $data);
This is a bug in the pdo driver... I'm going to check github to see if this has been fixed or send a pull request to fix it. This issue has been fixed. I recommend updating your codeigniter install. I cloned the codeigniter repo @ github and was not able to replicate the error.
here is the bug: line 197 in pdo_driver.php
if (is_numeric(stripos($sql, 'SELECT')))
{
$this->affect_rows = count($result_id->fetchAll());
$result_id->execute();
}
else
{
$this->affect_rows = $result_id->rowCount();
}
here is the fix:
if (is_numeric(stripos($sql, 'SELECT')) && stripos($sql, 'SELECT') == 0)
{
$this->affect_rows = count($result_id->fetchAll());
$result_id->execute();
}
else
{
$this->affect_rows = $result_id->rowCount();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With