Re: FB and DO long time building?
| From: | Justin Patrin | Date: | Tue, 18 Oct 2005 22:11:03 +0000 |
| Subject: | Re: FB and DO long time building? | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21535@lists.php.net to get a copy of this message | ||
On 10/18/05, Zane <softwarezman@hotmail.com> wrote:
> Ok. So it sounds retarded. I know that. I can practically taste the sarcasm
> :P.
>
> I know enough to build a 25 table database that tracks high altitude and
> medium altitude mission information and put it all in a web-based user
> interface with FB and DO components powering the whole thing :). Yea, it may
> not be a big deal to you and all but I have 2 squadrons in this country and
> 2 more outside that I'm implementing this specific database and PEAR modules
> with. And going by AF standards that's a pretty big deal! I'm not saying
> this to toot my own horn, but I am just saying I've worked on this quite a
> bit (almost a full year now!) And this is my first programming language, and
> first project really, so... forgive the stupid questions please.
>
> I was just hoping for something that might help pinpoint the extra time that
> seems like it shouldn't be there.
>
> I use auto complete fields in 3 places and 4 dropdown menus that pull from
> the same data, all of it pulled via $_SESSION variables so it doesn't have
> to hit the database every single time it does a refresh or submit (about 10k
> records a piece) I've tried commenting out those fields and it doesn't
> impact the time it takes to load, and I'm at a bit of a loss.
>
> If all I can get is sarcasm, please hold it and I'll find another route.
Sorry, I was just wondering why you'd ask such a question when the
answer was staring you in the face.
What's happening is that this is where FormBuilder is building the
form. The form is always built from scratch and it will always pull
from the DB for link fields and such. If you have 4 select boxes it
will be getting 4 sets of records from the DB on every getForm() call.
Even if they're the same table the query/pull will be done 4 times.
If you want to "cache" this I suggest using getForm once when the user
first comes to the page then saving the form object (returned from
getForm()) into your session. The downside to this is that the
defaults won't get updated (say, if an error happens and you need to
re-fill out the form, the values won't be in there) and if you used
the same form for multiple records you would get the wrong information
for the records.
These can be fixed in various ways ($form->setDefaults($_POST) for the
re-edit one and $form->setDefaults($do->toArray()) for a new DO) but
it will probably not be 100% right, especially if you are using
linkNewValue.
If you have 4 link fields which link to the same table you could
create a preGenerateForm method which pulls the link options via
$fb->getSelectOptions('fieldName') and stores them in the session.
Then you use those options to create 4 preDefElements for the 4
fields.
> Thanks.
>
> Zane
>
> -----Original Message-----
> From: Justin Patrin [mailto:papercrane@gmail.com]
> Sent: Tuesday, October 18, 2005 5:26 PM
> To: Zane
> Cc: pear-general@lists.php.net
> Subject: Re: [PEAR] FB and DO long time building?
>
> On 10/18/05, Zane <softwarezman@hotmail.com> wrote:
> > Hey everybody,
> >
> >
> >
> > I've been trying to benchmark some of my forms and such to try and figure
> > out where they are taking the longest to load. I have one form that has
> > multiple linked tables and about 15 fields total, and I think I limited
> the
> > time lag down to one section of code. I was just trying to figure out what
> > exactly happens between the code fragments?
> >
> >
> >
> > The longest delay (about a full second or so on average) is between
> > preFormGenerate and postFormGenerate. I've put time marks at the end of
> > preFormGenerate and beginning of postFormGenerate to try and limit it as
> > much as possible. Can anybody tell me exactly what happens between those
> two
> > functions that might have such a big time lag? I'm using the methods based
> > on the pdf file from the conference (updated pdf) using the DO getting the
> > redord, passing it to the builder object and then passing it to the
> > getForm() command with the getForm pulling from the $_SERVER['url'] (I
> know
> > its not 'url' but can't remember the exact code sorry.) Any information
> > would be greatly appreciated!
> >
> >
> >
> > Also I'm sorry about not providing code snippets, but the code is on a
> > classified network and I have a hard time getting anything off of it due
> to
> > security reasons. Not fun. But anything would be helpful! Thanks!
> >
>
> How much do you know about FormBuilder? What do you *think* happens
> between *PRE* and *POST* GenerateForm?? Perhaps....GenerateForm! Yes,
> the *form* is *generated* between those calls!
>
--
Justin Patrin