actually - this should work ..
$sometable->setFrom(new DataObjects_Sometable);
Regards
Alan
Alan Knowles wrote:
Sorry for not getting back sooner - been a bit busy, with php#, and
fixing my sons windows box (that he seems to have destroyed :)
Hi all, thanks in advance for any feedback.
I am try to run a series of validation on data before running an
insert or delete or whatever.
The thing is that if I run a fetch() on the data, and then
subsequently try an insert(), the data that was set during the
fetch() is still assigned to the member vars.
Is there some way to simply 'reset' an instance of the DO class so
that it assumes all member var information is empty?
At present no, there are a number of reasons for this - primarily, if
you extend the class and add some extra variables eg.
$this->percentSold = $this->inStock / $this->maxStock;
there is is not really 100% consistant way of removing them.
A simple method, obviously would be just to take the table definition,
and reset that eg. something like
$keys = array_keys($this->_get_table());
foreach ($keys as $k) {
unset($this->$k);
}
If you think this is valueable - I'll add it as
DB_DataObject::unsetObjectVars();
The other option would be to unset everything that is not private : eg.
$keys = array_keys(get_object_vars());
foreach ($keys as $k) {
if ($k{0} == '_') continue;
unset($this->$k);
}
The best way to do it really is to create new instances of the object.
, or to clone the object.., rather than working on the same object all
the time..
out of interest - are you looking at using it for phpshop? or just
another project?
Regards
Alan
This will help when doing multiple validation checks followed by an
update/insert/delete from the database.
Thanks!
Pablo
--
Can you help out?
Need Consulting Services or Know of a Job?
http://www.akbkhome.com
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|
Try Searching:
servers, voip, java, networking, microsoft ...
|
|
|
|