Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

difference between Mage::getResourceModel() and Mage::getModel()
 
westymatt
Jr. Member
 
Total Posts:  4
Joined:  2008-05-22
 

What is the difference between Mage::getModel() and Mage::getResourceModel()?

 
Magento Community Magento Community
Magento Community
Magento Community
 
srinigenie
Guru
 
Avatar
Total Posts:  539
Joined:  2008-02-04
 

ResourceModel is the layer that interacts with the Database objects and frames the queries.
Models are classes that uses the resource models to execute business logic.
http://www.magentocommerce.com/wiki/doc/magento-architecture

 
Magento Community Magento Community
Magento Community
Magento Community
 
stereotomy
Jr. Member
 
Total Posts:  28
Joined:  2008-02-10
 

the graph is so self explanatory smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
christopherhanson
Jr. Member
 
Total Posts:  3
Joined:  2010-10-17
Rotherham
 

lol ye, i guess that is self explanatory :D lol

 
Magento Community Magento Community
Magento Community
Magento Community
 
zuzuleinen
Jr. Member
 
Total Posts:  8
Joined:  2012-02-19
 

I’m a little confuse. So, using Mage::getResourceModel() you can return data, but you can also return data using Mage::getModel(). So my question is which one to use to return some data and why?

 
Magento Community Magento Community
Magento Community
Magento Community
 
barnyshergold
Member
 
Avatar
Total Posts:  53
Joined:  2011-02-05
 
arabgento - 22 February 2012 05:54 AM

this is almost like concept orm
read http://en.wikipedia.org/wiki/Object-relational_mapping
the technique is already in zend
if you want use getRsourceModel() Always try to use inside class model
and use object instancied from model class because is the couche or map created on top of sql (in your case Resource) for speaking with php object
hte exprt sql can work inside resource for creating complex auery
and expert php use th model object for speaking with our logic
in magento and zend is not very structured orm it’s small orm
but in world php you can see doctrine2 in very powerful and have nic concept in version 2 must structur and structure you can cach your query in cache

I’m English and I didn’t understand anything you said in this post....

 
Magento Community Magento Community
Magento Community
Magento Community
 
zuzuleinen
Jr. Member
 
Total Posts:  8
Joined:  2012-02-19
 

Hey guys stop it,

This is not a linguistic forum smile I appreciate arabgento’s help even tough I didn’t quite understand his full answer.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top