Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Updating one field in database using CakePhp?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.67k
    Comment on it

    Hello Readers,

    Below is used to update the single field in CakePHP.

    In CakePHP, if we can update the one field into the database to do this w have two methods to update the field.

    1> First using savefield() method:

    Example:

    $this->ModelName->id=$id;
    $this->ModelName->saveField("fieldName","value");

    In the above example, we have used the model id (which id record is updated) and used savefield("fieldName","value") method which having 2 parameters fieldname and it's value.

    2> Second one is using the updateAll() method:

    $this->Model->updateAll(array("fieldName"=>"value"),array("fieldName"=>"condition"));

    Example:

    In the above example code, we have used updateAll(array("fieldName"=>"value")) method having fieldname and its value.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: