Mage_Core_Model_Mysql4_Resource Class Reference

List of all members.

Public Member Functions

 __construct ()
 getDbVersion ($resName)
 setDbVersion ($resName, $version)

Protected Attributes

 $_read = null
 $_write = null
 $_resTable = null

Static Protected Attributes

static $_versions = null


Detailed Description

Mysql Model for module

Definition at line 32 of file Resource.php.


Constructor & Destructor Documentation

__construct (  ) 

Definition at line 39 of file Resource.php.

00040     {
00041         $this->_resTable = Mage::getSingleton('core/resource')->getTableName('core/resource');
00042         $this->_read = Mage::getSingleton('core/resource')->getConnection('core_read');
00043         $this->_write = Mage::getSingleton('core/resource')->getConnection('core_write');
00044     }


Member Function Documentation

getDbVersion ( resName  ) 

Get Module version from DB

Parameters:
string $moduleName
Returns:
string

Definition at line 52 of file Resource.php.

00053     {
00054         if (!$this->_read) {
00055             return false;
00056         }
00057 
00058         if (is_null(self::$_versions)) {
00059             // if Core module not instaled
00060             try {
00061                 $select = $this->_read->select()->from($this->_resTable, array('code', 'version'));
00062                 self::$_versions = $this->_read->fetchPairs($select);
00063             }
00064             catch (Exception $e){
00065                 self::$_versions = array();
00066             }
00067         }
00068         return isset(self::$_versions[$resName]) ? self::$_versions[$resName] : false;
00069     }

setDbVersion ( resName,
version 
)

Set module wersion into DB

Parameters:
string $moduleName
string $version
Returns:
int

Definition at line 78 of file Resource.php.

00079     {
00080         $dbModuleInfo = array(
00081             'code'    => $resName,
00082             'version' => $version,
00083         );
00084 
00085         if ($this -> getDbVersion($resName)) {
00086             self::$_versions[$resName] = $version;
00087             $condition = $this->_write->quoteInto('code=?', $resName);
00088             return $this->_write->update($this->_resTable, $dbModuleInfo, $condition);
00089         }
00090         else {
00091             self::$_versions[$resName] = $version;
00092             return $this->_write->insert($this->_resTable, $dbModuleInfo);
00093         }
00094     }


Member Data Documentation

$_read = null [protected]

Definition at line 34 of file Resource.php.

$_resTable = null [protected]

Definition at line 36 of file Resource.php.

$_versions = null [static, protected]

Definition at line 37 of file Resource.php.

$_write = null [protected]

Definition at line 35 of file Resource.php.


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

Generated on Sat Jul 4 17:23:59 2009 for Magento by  doxygen 1.5.8