Mage_Directory_Model_Mysql4_Region Class Reference

List of all members.

Public Member Functions

 __construct ()
 getIdFieldName ()
 load (Mage_Directory_Model_Region $region, $regionId)
 loadByCode (Mage_Directory_Model_Region $region, $regionCode, $countryId)
 loadByName (Mage_Directory_Model_Region $region, $regionName, $countryId)

Protected Attributes

 $_regionTable
 $_regionNameTable
 $_read
 $_write


Detailed Description

Definition at line 28 of file Region.php.


Constructor & Destructor Documentation

__construct (  ) 

Definition at line 47 of file Region.php.

00048     {
00049         $resource = Mage::getSingleton('core/resource');
00050         $this->_regionTable     = $resource->getTableName('directory/country_region');
00051         $this->_regionNameTable = $resource->getTableName('directory/country_region_name');
00052         $this->_read    = $resource->getConnection('directory_read');
00053         $this->_write   = $resource->getConnection('directory_write');
00054     }


Member Function Documentation

getIdFieldName (  ) 

Definition at line 56 of file Region.php.

00057     {
00058         return 'region_id';
00059     }

load ( Mage_Directory_Model_Region region,
regionId 
)

Definition at line 61 of file Region.php.

00062     {
00063         $locale = Mage::app()->getLocale()->getLocaleCode();
00064         $systemLocale = Mage::app()->getDistroLocaleCode();
00065 
00066         $select = $this->_read->select()
00067             ->from(array('region'=>$this->_regionTable))
00068             ->where('region.region_id=?', $regionId)
00069             ->join(array('rname'=>$this->_regionNameTable),
00070                 'rname.region_id=region.region_id AND (rname.locale=\''.$locale.'\' OR rname.locale=\''.$systemLocale.'\')',
00071                 array('name', new Zend_Db_Expr('CASE rname.locale WHEN \''.$systemLocale.'\' THEN 1 ELSE 0 END sort_locale')))
00072             ->order('sort_locale')
00073             ->limit(1);
00074 
00075         $region->setData($this->_read->fetchRow($select));
00076         return $this;
00077     }

loadByCode ( Mage_Directory_Model_Region region,
regionCode,
countryId 
)

Definition at line 79 of file Region.php.

00080     {
00081         $locale = Mage::app()->getLocale()->getLocaleCode();
00082 
00083         $select = $this->_read->select()
00084             ->from(array('region'=>$this->_regionTable))
00085             ->where('region.country_id=?', $countryId)
00086             ->where('region.code=?', $regionCode)
00087             ->join(array('rname'=>$this->_regionNameTable),
00088                 'rname.region_id=region.region_id AND rname.locale=\''.$locale.'\'',
00089                 array('name'));
00090 
00091         $region->setData($this->_read->fetchRow($select));
00092         return $this;
00093     }

loadByName ( Mage_Directory_Model_Region region,
regionName,
countryId 
)

Definition at line 95 of file Region.php.

00096     {
00097         $locale = Mage::app()->getLocale()->getLocaleCode();
00098 
00099         $select = $this->_read->select()
00100             ->from(array('region'=>$this->_regionTable))
00101             ->where('region.country_id=?', $countryId)
00102             ->where('region.default_name=?', $regionName)
00103             ->join(array('rname'=>$this->_regionNameTable),
00104                 'rname.region_id=region.region_id AND rname.locale=\''.$locale.'\'',
00105                 array('name'));
00106 
00107         $region->setData($this->_read->fetchRow($select));
00108         return $this;
00109     }


Member Data Documentation

$_read [protected]

Definition at line 38 of file Region.php.

$_regionNameTable [protected]

Definition at line 31 of file Region.php.

$_regionTable [protected]

Definition at line 30 of file Region.php.

$_write [protected]

Definition at line 45 of file Region.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:07 2009 for Magento by  doxygen 1.5.8