dongxieyi9115 2014-04-22 18:03
浏览 310

CodeIgniter affected_rows()返回-1

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料
    • ¥15 使用R语言marginaleffects包进行边际效应图绘制