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

Code DB Link
 
yshahin
Jr. Member
 
Avatar
Total Posts:  30
Joined:  2008-05-14
 

Can someone explain to me how the DB is linked to the code
how do i retrieve data? and how do i insert data?

is there a class that does this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

Unfortunately not as easy as that.  At the very lowest level is the Zend Database Framework.  Varien abstracts that to implement it’s database functions.  On top of that are the various module’s and how they access it.  There is a resource model that holds functions to access the database that is specific to the XML configuration setup for each module.  Here is the code to run direct queries on the database.  Not the most correct way but it will work.

$w Mage::getResourceSingleton(’core/resource’)->getConnection(’core_write’);
$result $w->query(’select â€™entity_id’ from â€™catalog_product_entity’);
if (!
$result{
return false;
}
$row 
$result->fetch(PDO::FETCH_ASSOC);
if (!
$row{
return false;
}

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
yshahin
Jr. Member
 
Avatar
Total Posts:  30
Joined:  2008-05-14
 

thanx, this might be useful
but i wanted to understand the normal flow of the db communication

the one recommended and used by the magento team
so i can understand how to communication from my module

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

Since there hasn’t been a lot of communication about that and most of the community is struggling it’s way through it, it is tough to say.  The “correct” way is to create your new module and then using models implement the calls and functions you need and then as you said in your other post, use the get, set, has, uns naming to call what you need.

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
yshahin
Jr. Member
 
Avatar
Total Posts:  30
Joined:  2008-05-14
 

but the set get dont reflect in the database
they store the data in the array _data

where and when does the sync happen between the db and the array? or it doesn’t sync?

Did you find anything about that?

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