Re: DataOjbects to QuickForms and Back

From: Date: Tue, 19 Oct 2004 21:54:43 +0000
Subject: Re: DataOjbects to QuickForms and Back
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-14981@lists.php.net to get a copy of this message
No idea. What kind of rules are you putting in? Could you show us some code? On Tue, 19 Oct 2004 16:49:20 -0500, Sparacio, Sal <salsparacio@newton-associates.com> wrote: > > > Ok, Thanks ill put one with the "count()" in. > > Any clue as to why when the rules don't validate, it causes a php stack over > flow? > > -- Sal > > -----Original Message----- > From: Justin Patrin [mailto:papercrane@gmail.com] > Sent: Tuesday, October 19, 2004 4:35 PM > To: Sparacio, Sal > Cc: pear-general@lists.php.net > Subject: Re: [PEAR] DataOjbects to QuickForms and Back > > > On Tue, 19 Oct 2004 16:15:48 -0500, Sparacio, Sal > <salsparacio@newton-associates.com> wrote: > > > > > > Own QuickForm, should I try to use ( don't know how but. ) FormBuilder. > > Latest Stable ver of QF. > > > > > > Query + Row Testing Code > > > > #### CODE #### > > > > // Perform the query > > > > $hud1->whereAdd('nreo_num =\'' . $_REQUEST['id'] . > > '\''); > > $hud1->find(); > > > > > > $total_returned = $hud1->count(); > > > > if ($total_returned < 1) > > This can be simplified. You don't need to find() and count(). find() > is only really when you want rows. count() is for getting the # of > rows only. You can either do: > > $hud1->whereAdd('nreo_num =\'' . $_REQUEST['id'] . > '\''); > if ($hud1->count() < 1) { > > > OR > > $hud1->whereAdd('nreo_num =\'' . $_REQUEST['id'] . > '\''); > if ($hud1->find() < 1) { > > count() should be the faster of the two. > > > > { > > //$hud1->nreo_num=$_REQUEST['id']; > > $hud1->insert(); > > } > > > > echo "<BR><BR><BR> !!!! -- $total_returned -- !!!!! > > <BR><BR><BR> "; > > > > $hud1->fetch(); > > > > > > #### CODE #### > > > > Sorry for being a noobie, but What DataObject class? > > The on for the table you're using. If you haven't modified it > manually, don't worry about it. > > > > > -- Sal > > ( Thanks you all your help. ) > > > > -----Original Message----- > > From: Justin Patrin [mailto:papercrane@gmail.com] > > Sent: Tuesday, October 19, 2004 4:09 PM > > To: Sparacio, Sal > > Cc: pear-general@lists.php.net > > Subject: Re: [PEAR] DataOjbects to QuickForms and Back > > > > > > On Tue, 19 Oct 2004 15:51:20 -0500, Sparacio, Sal > > <salsparacio@newton-associates.com> wrote: > > > > > > > > > Thanks for the response Justin, > > > > > > It was the primary key problem. I hate that my DBA got fired, anyway.. > > That > > > worked just fine if there is data that's already there. What I want the > > form > > > to do when call is .. if there is not a row in the table with that ID I > > want > > > it just to create a blank (null) row. I did a count() and then did: if > > count > > > < 1 than insert(). That worked and inserted the nulls into the db just > > fine. > > > Now the problem, I went to test out the form again and when I did not > > enter > > > a field that was 'required' by a rule, php freaked out and said:: " > > > PHP > > has > > > encountered a Stack overflow ". It only does that if, I forget something > > > that is required in the rules. Btw, the rules worked before all this, I > > > tired putting spaces after the DO put the nulls in but that did not work > > > either. > > > > > > Just to restate:: If the rule don't validate it will cause a Stack > > Overflow > > > error .. but if everything is ok, than It will update the form. > > > > > > > Is this using FormBuilder or your own QuickForm? What version fo > > QuickForm do you have installed? > > > > Where exactly are you doing that count() call? What does the > > DataObject class look like? > > > > > > > > -- Sal > > > > > > > > > > > > -----Original Message----- > > > From: Justin Patrin [mailto:papercrane@gmail.com] > > > Sent: Tuesday, October 19, 2004 12:41 PM > > > To: Sparacio, Sal > > > Cc: pear-general@lists.php.net > > > Subject: Re: [PEAR] DataOjbects to QuickForms and Back > > > > > > > > > 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-- > > > -- > paperCrane --Justin Patrin-- !DSPAM:41758cc03301608563879! -- paperCrane --Justin Patrin--

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