我一直在努力了解Magento并且我在wiki上阅读了很多内容,但我无法弄清楚Magento如何使用数据库表?因为我没有看到任何SQL
答案 0 :(得分:1)
我建议您阅读Alan Storm撰写的这篇博文: http://alanstorm.com/magento_models_orm
他解释了对Magento ORM系统的反应,我认为整个网站对于任何Magneto开发人员来说都是一个很好的资源。
答案 1 :(得分:0)
从knowledge base开始阅读第5章。
你并不是真的在问一个问题,所以没有人可以提供具体的帮助,我总是发现你做得最好,我发现用magento搞乱的最好办法就是创建一个test.php
文件shell/
具有以下内容:(例如)
<?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();
然后你可以从控制台运行:
php test.php
并在我的示例中返回
running ..string(11) "Extra Large"
希望这有助于你,下次更具体。
答案 2 :(得分:0)
如果您观看MySQl日志,magento的调用有时可能长达500行或更长......这些调用是使用XML文件动态构建的。手动操作Magento数据的最佳方法是使用MAGE::
调用或使用直接数据库连接:
$read = $resource->getConnection('core_read');
$sql = "select * from [YOUR_TABLE] where 1 limit 1";
$result = $read->query($sql);
它或者看起来像是:
$value = 'some value';
$item->setData('some_key', $value);
$item->save();
Magento是面向对象的,因此这些是在Magento中检索/设置数据的最常用和最常用的方法。我希望有所帮助。