Re: "unneccessary" query
On May 2, 11:44 am, QXY <q...@qxy.hu> wrote:
> Hello!
>
> http://bin.cakephp.org/saved/66911
>
> First of all, I have to tell you I'm learning CakePHP, so if you see
> something weird
> please do not laugh or give negative criticism, because everybody was
> beginner once. ;)
I'm not laughing I'm wondering why your code looks so different from
how the book, and everyone else, writes their code.
> where in the book does it suggest doing create(find()); ?
>
> Nowhere, but I don't understand, what is the problem? create(find()) or
> simply using create?
nesting calls like that, if nothing else , will make your code harder
to debug/read.
> why are you now passing false to create ..?
>
> "Optional data array to assign to the model after it is created. If null
> or false, schema data defaults are not merged."
> I don't want defaults to be loaded to model. What's wrong with this?> It's probably in your interest to check the api.
My Mistake.
>
> I'm doing that all time! :)> I hope you've only got a few members because that code doesn't look
> > like it's going to be very robust with a large amount of data. It's
> > also be quite hilarious to see how it acts if membersXmlArray is
> > empty :D
>
> This action performs an import as it's name says, running once/day by admin.
> What's the meaning the number of my members in this case?
does your code work if membersXmlArray is 10k rows?
> The source of membersXmlArray provides that it wont be empty. Worst case, an
> empty array makes foreach running 0 time, so what's the problem again?
So, if through unforseen-error the xml input isn't parsable or any
circumstance where you accidentally call this method with an empty
array - you're happy it's going to truncate your table?
>
> I really wonder what's wrong with my (new) code? It does the job well by
> queries that reading/writing only neccessary fields. Thanks in advance!
the find queries can come from many places. any call to exists, or
save are going to check if the row exists on the db. But I wouldn't
worry about a 0-1ms extra db call until it's your bottleneck (which
is unlikely to ever happen)
AD
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home