Git Product home page Git Product logo

Comments (6)

jschreuder avatar jschreuder commented on August 24, 2024

Was away most of today. No time to fully look into this tonight but it sounds logical. On the other hand, the affected row count from Model::update() should always be 1. If it's not something went wrong (Model::update() only updates the current instance, no others)

from core.

WanWizard avatar WanWizard commented on August 24, 2024

If you (with MySQL) fetch a record using Model::find(1) and then directly save it, affected rows is zero (update went ok, but no rows were updates since all values were the same).

If your controller contains a

if ($model->save())
{
    // success
}
else
{
    // failure
}

Your application will generate an error if the user requests a record, and clicks save without changing anything.

from core.

jschreuder avatar jschreuder commented on August 24, 2024

Actually, is_changed() is run before save() is executed and when no change is detected it will always return true

from core.

WanWizard avatar WanWizard commented on August 24, 2024

Issue is in typing. MySQL stores everything as string, so when you retrieve a record, all column values are strings, However, the fields on my forms and the validation routines behind it aren't, so an int column which was retrieved as "10", will be set to 10 (int!) before calling save(), and I assume that is_changed() will then return true, although for MySQL still nothing has changed.

from core.

jschreuder avatar jschreuder commented on August 24, 2024

I just changed Orm\Query::update() to return true when affected rows is 0. fuel/orm@42e17df6

from core.

WanWizard avatar WanWizard commented on August 24, 2024

Thanks. This can be closed then.

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.