[Solar-talk] model branch: insert(), _applyFilters() & autoincrement
Rodrigo Moraes
rodrigo.moraes at gmail.com
Sat Feb 17 08:36:49 PST 2007
In the model branch, it seems that there is a problem when you try to
insert a record with an autoincremented primary key because it will
not validate in _applyFilters() - there is no 'validateInt' yet for
the autoincremented value.
A dirty workaround to let things going is to cheat the filter in
insert(). We set a fake primary key and then unset it before saving:
$this->_data[$this->_col_primary] = 1;
// filter the data (sanitize and validate)
$this->_applyFilters();
unset($this->_data[$this->_col_primary]);
This trick uses the pattern ' FORCEPS' from WOP - Workaround Oriented
Programming, which consists in setting a hardcoded value to stop a
bug. :P
Please just ignore this message, Paul. It's part of the "model branch
hacks to let things going" series. :)
rodrigo
-------------------------------
http://tipos.com.br
More information about the solar-talk
mailing list