Wednesday, 9 October 2013

new features in php cake

Leave a Comment

Models

 

  1. Model::saveAll(),

  2.  Model::saveAssociated(),

  3.  Model::validateAssociated()

     

    ex. Model::saveAll() and friends now support passing the fieldList for multiple models.

     

    $this->SomeModel->saveAll($data, array(
        'fieldList' => array(
            'SomeModel' => array('field_1'),
            'AssociatedModel' => array('field_2', 'field_3')
        )
    ));
    
    Model::saveAll() and friends now can save unlimited levels deep. Example:
    $data = array( 'Article' => array('title' => 'My first article'), 'Comment' => array( array('body' => 'Comment 1', 'user_id' => 1), array('body' => 'Save a new user as well', 'User' => array('first' => 'mad', 'last' => 'coder')) ), ); $this->SomeModel->saveAll($data, array('deep' => true));




0 comments:

Post a Comment