Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
ClassRegistry::init vs loadModel
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Henrik Gemal  
View profile  
 More options Feb 9, 7:57 am
From: Henrik Gemal <henrikge...@gmail.com>
Date: Mon, 9 Feb 2009 04:57:24 -0800 (PST)
Local: Mon, Feb 9 2009 7:57 am
Subject: ClassRegistry::init vs loadModel
I'm not sure what the "most" correct way to dynamicly load a model is:

ClassRegistry::init("model_name")
or
loadModel("model_name")

?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mscdex  
View profile  
 More options Feb 9, 8:59 am
From: mscdex <msc...@gmail.com>
Date: Mon, 9 Feb 2009 05:59:52 -0800 (PST)
Local: Mon, Feb 9 2009 8:59 am
Subject: Re: ClassRegistry::init vs loadModel
On Feb 9, 7:57 am, Henrik Gemal <henrikge...@gmail.com> wrote:

> I'm not sure what the "most" correct way to dynamicly load a model is:

> ClassRegistry::init("model_name")
> or
> loadModel("model_name")

> ?

I use App::Import if I'm going to use a model instance more than once.
Otherwise ClassRegistry::init can be used for one-time usage (e.g.
ClassRegistry::init("Foo")->find("all");).

However,  you should make sure you are not loading a model in which
the current model (of your controller) has an association with. If it
does, then you can just do $this->Bar->Foo->find("all"); instead if
"Bar" is the current model.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gwoo  
View profile  
(6 users)  More options Feb 9, 1:16 pm
From: Gwoo <gwoo.cake...@gmail.com>
Date: Mon, 9 Feb 2009 10:16:42 -0800 (PST)
Local: Mon, Feb 9 2009 1:16 pm
Subject: Re: ClassRegistry::init vs loadModel
Ok hopefully this will be the last time we need to explain this...

App::import() only includes the file. So you would new to create a new
instance every time. This is not recommended

ClassRegistry::init() loads the file, adds the instance to the a
object map and returns the instance. This is an easy and convenient
way to access models.

Controller::loadModel(); Uses ClassRegistry::init() adds the model to
a property of the controller and also allows persistModel to be
enabled.

While you "can" do any of these things, you should ask yourself why
you are creating dependencies on models that are not natural to the
controller. If you "have" to do use any of these, then I would do so
in reverse order of the way i described them. IE, Controller::loadModel
() then CR::init() and actually I never use App::import() for models.

Hope this helps.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
gmwebs  
View profile  
 More options Feb 10, 6:54 am
From: gmwebs <gmw...@googlemail.com>
Date: Tue, 10 Feb 2009 03:54:37 -0800 (PST)
Local: Tues, Feb 10 2009 6:54 am
Subject: Re: ClassRegistry::init vs loadModel
Gwoo, I apologise if I have missed any posts on this in the past,
but...

I thought that loadModel() was deprecated? I remember going through
all my code and changing it to App::import based on the warning
message "loadModel is deprecated see App::import
('Model', 'ModelName');"?

Has this (or the preferred method) changed?

Again, sorry if I am just being dumb!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gwoo  
View profile  
 More options Feb 10, 11:44 am
From: Gwoo <gwoo.cake...@gmail.com>
Date: Tue, 10 Feb 2009 08:44:45 -0800 (PST)
Local: Tues, Feb 10 2009 11:44 am
Subject: Re: ClassRegistry::init vs loadModel
Yes the old loadModel() function from basics was deprecated.
However the loadModel() method in Controller is still used.
http://api.cakephp.org/class/controller#method-ControllerloadModel

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Miles J  
View profile  
 More options Feb 10, 4:51 pm
From: Miles J <mileswjohn...@gmail.com>
Date: Tue, 10 Feb 2009 13:51:12 -0800 (PST)
Local: Tues, Feb 10 2009 4:51 pm
Subject: Re: ClassRegistry::init vs loadModel
    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google