I have some functions of insert/update in my Codeigniter project, and I check that they succeed with the function affected_rows()
. I have tested it locally and it works perfect, but when I uploaded to my server it doesn't work anymore, it always returns -1 though in my database it DOES insert/update.
What could be my problem?
Thanks in advance (:
An example of my code:
$this->db->insert('permisos', $permiso);
return $this->db->affected_rows() > 0;
UPDATE 1:
I tried with echo $this->db->affected_rows()
and it returned -1, so my statement returns FALSE
.
I'm working with MySQL 5.6.16 and PHP 5.5.11 in development; MySQL 5.0.77 and PHP 5.2.9 in production. My Codeigniter version is 2.1.4.
UPDATE 2:
I found out what's my problem, I was using mysqli driver and apparently my server does not support it, so I changed it back to mysql and now this is working, but... I was set it to mysqli because I had troubles with some stored procedures (this)... so... I need another workaround xD.
Somewhere I saw something like this
$insert = $this->db->insert('permisos', $permiso);
if($insert){
return TRUE;
}else{
return FALSE;
}
And it seems to work (with mysqli driver) but I'm not sure what it does exactly or if it's a reliable way... Is it?