Skip to content

Commit

Permalink
pre-release fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
romaninsh committed Jul 26, 2016
1 parent b688360 commit bba14e3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ This is our first maintenance release that solves several important issues.
* Change: calling ref() on object without active record will return you object without active record instead of exception
* Change: `$m->ref()` into non-existant hasOne() relation then [saving it will update field inside $m](http://agile-data.readthedocs.io/en/develop/relations.html?highlight=contact_id#relations-with-new-records).
* Added ability to call `save([$data])`, which will combine set() and save()
* Added support for `$model->title_field`
* Added [support for `$model->title_field`](http://agile-data.readthedocs.io/en/develop/model.html#title-field-and-id-field)
* added [$m->isDirty()](http://agile-data.readthedocs.io/en/develop/model.html#Model::isDirty)
* Added [afterUnload and beforeUnload hooks](http://agile-data.readthedocs.io/en/develop/model.html#hooks).
* Added support for [automated model reloading](http://agile-data.readthedocs.io/en/develop/expressions.html?highlight=reloading#model-reloading-after-save)
* Added support for advanced patterns described here:
Expand Down
16 changes: 14 additions & 2 deletions docs/model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ array:
.. php:method:: set
Set field to a specified value. The original value will be stored in
$dirty property
$dirty property. If you pass non-array, then the value will be assigned
to the :ref:`title_field`.

.. php:method:: unset
Expand Down Expand Up @@ -228,7 +229,16 @@ Full example::
Verify and convert first argument got get / set;

Title Field and ID Field
===========
========================

Those are to properties that you can specify in the model or pass it through defaults::

class MyModel ..
public $title_field = 'full_name';

or as defaults::

$m = new MyModel($db, ['title_field'=>'full_name']);


ID Field
Expand All @@ -252,6 +262,8 @@ ID Field

You must remember that only dirty fields are saved, though. (We might add replace() function though).

.. _title_field:

Title Field
-----------

Expand Down
18 changes: 18 additions & 0 deletions docs/persistence.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ There are several ways to link your model up with the persistence::

If record not found, will throw exception.

.. php:method:: save($data = [])
Store active record back into DataSet. If record wasn't loaded, store it as a new record::

$m->load(10);
$m['name'] = 'John';
$$m->save();

You can pass argumen to save() to set() and save()::

$m->unload();
$m->save(['name'=>'John']);

Save, like set() support title field::

$m->unload();
$m->save('John');

.. php:method:: tryLoad
Same as load() but will silently fail if record is not found::
Expand Down

0 comments on commit bba14e3

Please sign in to comment.