• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Calling Models

R

ragtek

Guest
#1
(my english is horrible and i'm not a author, so it's a minimalistic text;)

Even some Coders are using this, you should NEVER use
PHP:
$foo = new ModelName;
to create model instances!
If you do it this way, your model instances won't be using the xenforo plugin system (proxy classes)
which could cause problems

This are the ways how to call a model:

From Controller:
PHP:
$foo = $this->getModelFromCache('ModelName');
From Model
PHP:
$foo = $this->getModelFromCache('ModelName');
From all other parts:
PHP:
$foo = XenForo_Model::create('ModelName');
 

KozmoK

Active member
#2
Ragtek,

I hate to dirty up your post with this stupid question! Can I call a 3rd party (already a working add-on) model from within another controller, or model?
I'm going to edit the paypalProcessor to call my custom model and do a db function.

Thanks,

Koz
 

Bob

Well-known member
#3
Ragtek,

I hate to dirty up your post with this stupid question! Can I call a 3rd party (already a working add-on) model from within another controller, or model?
I'm going to edit the paypalProcessor to call my custom model and do a db function.

Thanks,

Koz
Yes
 
R

ragtek

Guest
#6
I would suggest to search for a good PHP IDE and to learn how to use it;)


XF_Model_User diagramm:
diagram.png

Hope this helps;)

Or you could use http://www.phpdoc.org/ or an alternative to get a nice API documentation