php - What does exclusive option in hasMany? -


in cakephp, there option called "exclusive" in "hasmany" field in models. documentation says:

when exclusive set true, recursive model deletion delete deleteall() call, instead of deleting each entity separately. improves performance, may not ideal circumstances.

but not clear. want know option exactly, , happens if don't use it? thanks.

say example, 1 author has many books.so can write in form of $hasmany association below,

   var $name = 'author';        var $hasmany = array('book' =>         array('classname' => 'book',             'conditions' => '',             'foreignkey' => 'author_id',             'dependent' => true,             'exclusive' => true          )     ); 

dependent: when dependent set true, recursive model deletion possible. in example, book records deleted when associated author record has been deleted.

exclusive – if set true, associated objects deleted in 1 sql statement without having beforedelete callback run.this improves performance, may not ideal circumstances.

now @ records in database

authors table =================== id    name     =================== 1     first author 2     second author  3     third author 

books table

================================== id   title   isbn       author_id ==================================   1    abc    6416446846   1 2    xyz    3146354313   1 3    pqr    8945468485   2 4    fgh    6434164656   2 5    rtt    1215445644   3 

now if delete record of author,all associated books particular author deleted.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -