Magento: veritabanı seçin

0 Cevap php


I am working on my first module for magento version 1.3.2.3. I have created a simple table (not EAV, just a primary key and 2 columns) and some classes to access it, following Alan Storm's articles which helped me a lot, but I can't figure out how to make a simple select: Alan explains how to load with the primary key, but not selecting rows that match some value.

normal MySQL Ben yazmak istiyorum In:

SELECT *
FROM my_table
WHERE some_field = '" . $someValue . "'

Bana istediğim sonuç veren bir parçacık bulduk:

$resource = new Mage_Core_Model_Resource();
$read = $resource->getConnection('core_read');
$select = $read->select() ->from('my_table') ->where('some_field = ?', $someValue);
return $read->fetchAll($select);

But there have to be an easier/prettier solution, using the model class I've created. The result will be a single row, not a collection.
I've tried everything I could think of, like:

return Mage::getModel('modulename/classname')->select()->where('some_field = ?', $comeValue); return Mage::getModel('modulename/classname')->load()->where('some_field = ?', $comeValue);
return Mage::getModel('modulename/classname')->load(array('some_field = ?', $comeValue));

ve daha fazla şeyler, ama hayır şans şimdiye kadar: ne eksik?

0 Cevap