Open ethanpil opened 10 years ago
@ethanpil What do you suggest the default behavior should be $mapper->reset($vfields = False) {
or $mapper->reset($vfields = True) {
. So by default virtual fields should be wiped out or done only on request.
I think we will do best to keep the default function the same to ensure backwards compatibility.
@jimymodi created PR https://github.com/bcosca/fatfree/pull/835 for this issue.
I don't like the idea to add virtual fields and then drop them later to reuse the object. This could cause unexpected side effects. At least the default value $vfields = false
is reasonable.
I don't think it should belong to reset()
, because this method is used to reset the cursor, not to modify the mapper structure.
Why not adding an adhoc()
method, so we can loop and clear all adhoc fields?
foreach ($mapper->adhoc() as $key)
$mapper->clear($key);
This solution also allows to filter adhoc fields out:
foreach ($mapper->adhoc() as $key)
if (preg_match('/^total_/',$key))
$mapper->clear($key);
How about $mapper->wipe()
or $mapper->reboot()
or something similar which can be used to simply restore the mapper to brand new status.
I propose we add an optional parameter to
$mapper->reset()
that will also remove all of the vfields.Per https://groups.google.com/forum/#!topic/f3-framework/RQA-NOcuBWk