title: Magento: select from database
body: <p>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 <a href="http://alanstorm.com/" rel="nofollow noreferrer">Alan Storm's articles</a> 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.</p>
  
  <p>In <i>normal MySQL</i> I'd write:  </p>
  
  <pre><code>SELECT *  
  FROM my_table  
  WHERE some_field = '" . $someValue . "'  
  </code></pre>
  
  <p>I've found a snippet which gives me the result I want:  </p>
  
  <pre><code>$resource = new Mage_Core_Model_Resource();  
  $read = $resource-&gt;getConnection('core_read');  
  $select = $read-&gt;select()
                 -&gt;from('my_table')
                 -&gt;where('some_field = ?', $someValue);  
  return $read-&gt;fetchAll($select);  
  </code></pre>
  
  <p>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.<br>
  I've tried everything I could think of, like:  </p>
  
  <pre><code>return Mage::getModel('modulename/classname')-&gt;select()-&gt;where('some_field = ?', $comeValue);
  return Mage::getModel('modulename/classname')-&gt;load()-&gt;where('some_field = ?', $comeValue);  
  return Mage::getModel('modulename/classname')-&gt;load(array('some_field = ?', $comeValue));  
  </code></pre>
  
  <p>and more stuff, but no luck so far: what am I missing??</p>