Hi everyone :)
Could someone please let me know wether I understand how the model
class works :
1) Models can be used in two different ways. The first way is to query
any amount of data from the datasource (or information about the model)
; and the second is to manipulate a specific row of data.
2) When manipulating a specific row of data, the 'id' field of the
Model object is set to the value of the primary key of the row of data
that is being manipulated. That field is set when calling functions
such as 'read' and 'save'.
3) The following functions are used when manipulating a single row of
data : set, create, setId, read, field, saveField, save, remove, del,
delete, exists, validate, invalidfields, invalidate, getID. The other
functions are used for querying data (or other functions that do not
work exclusively on a single row of data)
4) Out of the functions that work on a single row of data, the
following ones override or allow you to override the value of 'id' :
set, create, setId, read, save, remove, del, delete. The others expect
'id' to be set (field, saveField, validate, invalidfields, invalidate,
getID)
5) When writing functions that manipulate data in the model (or in a
behaviour), it is best to write the code so that the 'id' field can be
overriden. For instance the 'hide' method of the manual should be
written so :
function hide($id = null) {
if ($id) {
$this->id = id;
}
if (!$this->id) {
return;
}
$this->saveField('hidden', '1');
}
Is this all correct ?
Thanks,
Anselm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---