Re: DataOjbects to QuickForms and Back

From: Date: Tue, 19 Oct 2004 17:40:58 +0000
Subject: Re: DataOjbects to QuickForms and Back
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-14973@lists.php.net to get a copy of this message
On Tue, 19 Oct 2004 09:43:54 -0500, Sparacio, Sal <salsparacio@newton-associates.com> wrote: > I have setup DataObjects to query my database and all. I tell it what "id" ( > its the prim key ) to use and then use the find() then the fetch() commands. > > Then I use the setDefaults() command in QuickForms with the toArray() > command of Dataobjects to populate all the fields + set all the defaults for > radio buttons and such. > > ### CODE ### > > $hud1->nreo_num = $_REQUEST['id']; > > // Perform the query > > $hud1->find(); > $hud1->fetch(); > > $form->setDefaults($hud1->toArray()); > > ### CODE ### > > Now, is that the correct way to do it.. or did I take a long way around > something (It just seemed to easy for some reason, but it works). > > 2nd question is, after I validate() ( the QuickForms one ), I do.. > > ### CODE ### > > $hud1->setFrom($_POST); > > $hud1->whereAdd('nreo_num = 6000143896'); > > $hud1->update(); > > ### CODE ### > > It runs and my problem is that when it does UPDATE SQL statement, in the > "WHERE" section it puts all the old data. IE: where field1 = 'old_data', > AND > field2 = 'old_data' .. etc etc threw like 40 of the fields, instead of just > doing where NREO_num = 'blah'. So the MSSQL complains because I have a few > text fields and you cant do a "compare" ( where ) search on those types of > fields. Is there somewhere I can tell it just to use the "WHERE nreo_num = ' > blah ' .. and not the rest? > > -- Sal > I assume the nreo_num field is set up as a primary key? If it's not, that may be your problem. You can try this: $hud1->whereAdd(); $hud1->whereAdd('nreo_num = 6000143896'); If that doesn't work, I'm not sure why DO is putting everything in there. Probably because the primary key isn't set up or isn't set in the DO. Aside from all that, though, have you looked at DB_DataObject_FormBuilder? It does all this for you with a minimum of fuss and is very customizable. -- paperCrane --Justin Patrin--

« previous php.pear.general (#14973) next »