2
此問題適用於使用EAV資源模型或常規模型的模型。我想知道如何獲得選擇的save()
方法或load()
方法。獲取要查詢的模型您要保存Magento
例子是像
$product = Mage::getModel('catalog/product')->load(5);
我沒有花時間調試,只是想知道,如果有人知道了手。我不認爲Magento模型使用Zend_Db
作爲集合。
此問題適用於使用EAV資源模型或常規模型的模型。我想知道如何獲得選擇的save()
方法或load()
方法。獲取要查詢的模型您要保存Magento
例子是像
$product = Mage::getModel('catalog/product')->load(5);
我沒有花時間調試,只是想知道,如果有人知道了手。我不認爲Magento模型使用Zend_Db
作爲集合。
是,Magento模型卻使用了Zend_Db
內部,如Magento的著名Zend框架之上運行..
至於你的要求,得到一個模型的SQL,使用的EAV資源模型,是: -
$product = Mage::getModel('catalog/product')
->load(5)
->getSelect();
// For printing the whole SQL with the Collection
var_dump($product->printLogQuery(true));
// For printing only the SQL
var_dump($product->__toString());
希望它有幫助。
有趣.... – 2012-03-22 09:59:42
我想它不適用於自定義模型......我得到了致命的錯誤。調用非對象上的成員函數printLogQuery()。我猜getSelect()返回字符串,並在getCollection()方法後使用。 – 2012-10-16 13:48:08