/**
  * Returns an array of objects of class strClass mapped from SQL query
  * strSQL. eg:
  * <code>
  * $people = MyActiveRecord::('Person', 'SELECT * FROM person ORDER BY first_name');
  * foreach( $people as $person ) print $person->first_name;
  * </code>
  *
  * @static
  * @param string  strClass  The name of the class for which you want to return objects.
  * @param string  strSQL  The SQL query
  * @return  array array of objects of class strClass
  */
 static function FindBySql($strClass, $strSQL, $strIndexBy = 'id')
 {
     static $cache = array();
     $md5 = md5($strSQL);
     if (isset($cache[$md5]) && defined('MYACTIVERECORD_CACHE_SQL') && MYACTIVERECORD_CACHE_SQL) {
         return $cache[$md5];
     } else {
         if ($rscResult = MyActiveRecord::query($strSQL)) {
             $arrObjects = array();
             while ($arrVals = mysql_fetch_assoc($rscResult)) {
                 $arrObjects[$arrVals[$strIndexBy]] =& MyActiveRecord::Create($strClass, $arrVals);
             }
             mysql_free_result($rscResult);
             return $cache[$md5] = $arrObjects;
         } else {
             trigger_error("MyActiveRecord::FindBySql() - SQL Query Failed: {$strSQL}", E_USER_ERROR);
             return $cache[$md5] = false;
         }
     }
 }