Ahmad Khan
Ahmad Khan

Reputation: 529

Magento Tables and how they work with the database

I been trying to understand Magento and I read many things on the wiki, but I couldn't figure out How does Magento works with database tables? because I didn't see any SQL

Upvotes: 0

Views: 1516

Answers (3)

Customer Paradigm
Customer Paradigm

Reputation: 36

I would reccomend read over this blog post from Alan Storm: http://alanstorm.com/magento_models_orm

He explains quite abit about the Magento ORM system, and in my opinion that entire site is a great resource for any Magneto developer.

Upvotes: 1

Zak
Zak

Reputation: 7515

If you watch your MySQl log, the calls made by magento can sometimes be 500 lines long or longer ... These calls are dynamically constructed using XML files. The best way to manipulate Magento data manually is to use MAGE:: calls or use a direct database connection by using:

$read = $resource->getConnection('core_read');
$sql = "select * from [YOUR_TABLE] where 1 limit 1";
$result = $read->query($sql);

It's either that or calls that look like:

$value = 'some value';
$item->setData('some_key', $value);
$item->save();

Magento is object oriented, so those are the most commonly accepted and used ways to retrieve/set data in Magento. I hope that helps.

Upvotes: 0

jzahedieh
jzahedieh

Reputation: 1579

Read chapter 5 onwards from the knowledge base.

You are not really asking a question so no one can help on the specifics, I always find that you learn best by doing, I find the best way to mess around with magento is to create a test.php file in shell/ with the following: (for example)

<?php
require('abstract.php');

class Test extends Mage_Shell_Abstract
{
    function run(){ //call your functions here
        echo 'running ..';
        $this->database();
    }

    function database() { //you can create as many functions as you like
        $entityId = '4449'; //product id

        $product=Mage::getModel("catalog/product")->load($entityId);
        var_dump($product->getAttributeText('size'));
    }
}

$test = new Test();
$test -> run();

Then you can run from console: php test.php

and it returns in my example running ..string(11) "Extra Large"

Hope this helps you, next time be more specific.

Upvotes: 0

Related Questions