Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Unable to update with confidence just create nonesense

I can't update records. I either get errors or I fill colums up with nulls on a new record (how does that even happen using update?).

So can someone PLEASE tell me how to perform an update with partial data without having a nightmare:

If I have the following in my database

    id              3
    status      "old_status"
    desc        "this is a description"
    year        "2014"

Why won't $this->update(array("id" => 3, "status" => "new_status")) give me:

    id              3
    status      "new_status"
    desc        "this is a description"
    year        "2014"

at the end?

I've tried whitelist and $this->useDynamicUpdate(true); and setting allow nulls in mysql and

        'notNullValidations' => false

and various combinations but no joy.


DOH! Just dawned on me. Make sure you are using MyModelName::findFirst($id) not new MyModelName(); in your controller. I was ready to jump of a bridge then!

$this->useDynamicUpdate(true); is also being used.