Update Database Field Error CodeIgniter

前端 未结 5 605
悲&欢浪女
悲&欢浪女 2021-02-04 08:18

I am getting the following error message in CodeIgniter 2.1:

A PHP Error was encountered

Severity: Notice

Message: Array to string conversion

Filename: databa         


        
5条回答
  •  忘了有多久
    2021-02-04 09:17

    Just stumbled upon the exact same problem here. Fortunately, I'm using the same CI version. :)

    It's true that the answer from M_A_K helps remove the "Notice", but I don't think that is the right solution for the problem. So I decided to take a look at line 1407 in DB_active_rec.php and I believe that this is nothing but a minor bug in CI 2.1.2.

    Here's my fix. I simply changed the original code:

    $not[] = $k.'-'.$v;
    

    into this:

    $not[] = $k2.'-'.$v2;
    

    Voila! The "Notice" doesn't appear anymore. :)

    We can clearly see that line 1407 was not meant to use $k and $v because line 1407 is inside a foreach loop iterating through $v as $k2 and $v2.

    I hope I'm making myself clear.

提交回复
热议问题