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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算