Re: How to instantiate a model

2007-03-19 Thread Grant Cox

How is a class instance going to help you here?  Why not just store
the result of the find in a variable, and use that the second time?

However, it is probably a moot point - both cake and mysql will cache
query results, so you will probably find that second query (if run at
all) will take 1ms.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to instantiate a model

2007-03-19 Thread rtconner

Two different queries... same result.. caching does not help on this
one.

Well, what is the point of having all of this nice Model Class code
written if I'm not going to use it? Set/Get, Associations, Finds, all
sorts of Nifty tools I should like to use when needed.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to instantiate a model

2007-03-19 Thread John David Anderson (_psychic_)


On Mar 19, 2007, at 4:55 PM, rtconner wrote:


 Two different queries... same result.. caching does not help on this
 one.

 Well, what is the point of having all of this nice Model Class code
 written if I'm not going to use it? Set/Get, Associations, Finds, all
 sorts of Nifty tools I should like to use when needed.

I think we need to know a little more about what you're after in  
order to help out.

-- John

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to instantiate a model

2007-03-19 Thread rtconner

John, Really?? I doubt you do need more information... but I'll play
along.
The following two selects are summarized versions of what cakephp
creates

UserModel - find() generates:
 SELECT * FROM users WHERE 
 session_hash='thisisanobscurestringwhichcannotbeguessed';
Username comes from the session.
...

Then later using that data (in a controller) I need a Model Instance.
Right now I have
$this-User-id = $user_id;
$this-set('user', $this-User-read());

Which generates another query...
 SELECT * FROM users WHERE id=4;

Do you notice how I'm selecting the same data from the database twice?



On Mar 19, 4:59 pm, John David Anderson (_psychic_)
[EMAIL PROTECTED] wrote:
 On Mar 19, 2007, at 4:55 PM, rtconner wrote:



  Two different queries... same result.. caching does not help on this
  one.

  Well, what is the point of having all of this nice Model Class code
  written if I'm not going to use it? Set/Get, Associations, Finds, all
  sorts of Nifty tools I should like to use when needed.

 I think we need to know a little more about what you're after in
 order to help out.

 -- John


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to instantiate a model

2007-03-19 Thread rtconner

My typing skills suck. Sorry about the grammar errors.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to instantiate a model

2007-03-19 Thread nate

On Mar 19, 7:09 pm, rtconner [EMAIL PROTECTED] wrote:
 John, Really?? I doubt you do need more information... but I'll play
 along.

rtconnor: John has been providing support on this mailing list pretty
much since it's inception.  If he didn't need more information, he
wouldn't have asked for it.  I'm sure I don't have to remind you that
no one here is getting paid to answer your question, so it is most
certainly in your best interest to help them help you.

Also, asking for more information about a problem is often something
that happens when it appears that the person asking the question is
doing something they either shouldn't do or don't need to do.  Reading
the summary of your approach above, I would agree with that assessment.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to instantiate a model

2007-03-19 Thread Grant Cox

rtconnor: I still don't see a need for a model instance here.

Your first query, User-find(), will return the User data (as an
array), with appropriate associations loaded.
Your second query, User-read, will return User data (as an array),
with appropriate associations loaded.

Instead, try
$user = $this-User-find( ..your session hash conditions... )
$this-set( 'user', $user )


For future reference, model instances are used in cake as the
interface to the data layer - and in any one request there will only
be a single model instance created.  All data is returned as arrays.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to instantiate a model

2007-03-19 Thread rtconner

Nate, John...

I don't doubt his or anyone else's expertise around here. From my
viewings and usage of Cake, the code is amazingly written, and the
help around here has been about as good as I could hope for. No
complaints from me. Yes I know everyone supports for free. I try to
answer what questions I can in my still limited knowledge. I
definately want to give back to the community which supplied this
grand peice of software.



Grant..

Ok then... I'll try not making a Model instance. I have no actual
current need for it, I was just trying to consider the unkown future
and what needs it might hold.
. Actually I will try to set the UserModel-data Variable with the
results from the find, and see what happens. Now that I think about
it, that would actually solve my problem, the find returns results in
the same format as model-data holds them from what I know. That
should work quite well (in theory).
Well directly or indirectly I think you've answered my question.
Thanks


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---