abstract------------------------mysql4_abstract--------------mysql4_collection_abstract--------------------内核类的函数分析!!!

内核函数

mage_core_model_abstract

mage_core_model_mysql4_abstract

mage_core_model_mysql4_collection_abstract

 

使用mage::getmodel(core/abstract)的时候会指定$this->_resourceName和$this->_resourceCollectionName。

对于使用,已经做好文档,

 

下面这些是介绍上面三个系统类功能:

 

1.

mage_core_model_abstract

extends Varien_Object

 

1.1

//Set resource names

function _setResourceModel

1.2

//Get resource instance   @return Mage_Core_Model_Mysql4_Abstract

public function _getResource()

1.3

//Retrieve identifier field name for model      @return string

 public function getIdFieldName()

 

1.4

//Retrieve model object identifier  @return mixed

public function getId()

 

1.5

//Declare model object identifier value    @return  Mage_Core_Model_Abstract

public function setId($id)

 

1.6

//Retrieve model resource name   @return string

 public function getResourceName()

 

1.7

//Get collection instance         @return object

public function getResourceCollection()

 

1.8

//

public function getCollection()   ---->return $this->getResourceCollection();

 

1.9

// * Load object data           @return  Mage_Core_Model_Abstract

 public function load($id, $field=null)

 

1.10

//Save object data    @return Mage_Core_Model_Abstract

 public function save()

1.11

//Remove model onject related cache    @return Mage_Core_Model_Abstract

public function cleanModelCache()

 

1.12

//Delete object from database     @return Mage_Core_Model_Abstract

public function delete()

 

1.13

 public function getResource()

    {

        return $this->_getResource();

    }

 

故:mage_core_model_abstract

1.1

只能处理一些简单的关于数据库的操作。

在操作的时候,数据保存在自身的变量里面,只能进行save,delete,load等这些简单的操作。

1.2

得到mage_core_model_mysql4_abstract

mage_core_model_mysql4_collection_abstract的实例化对象。

1.3

得到id方面的函数

1.4

内存方面的函数

1.5

before,after,地球人都知道。

 

总体来说,作为一个入口,又能做一些简单的操作

 

2

mage_core_model_mysql4_abstract

extends Mage_Core_Model_Resource_Abstract

 

2.1

初始化

//

protected function _init($mainTable, $idFieldName)

    {

$this->_setMainTable($mainTable, $idFieldName);

}

2.1

//* Initialize connections and tables for this resource model

protected function _setResource($connections, $tables=null)

 

2.2

//Set main entity table name and primary key field name   @return Mage_Core_Model_Mysql4_Abstract

 protected function _setMainTable($mainTable, $idFieldName=null)

 

 

2.3

//Get primary key field name

public function getIdFieldName()

 

2.4

//* Get main table name

public function getMainTable()

 

2.5

// * Get table name for the entity

public function getTable($entityName)

 

2.6

//Retrieve table name for the entity separated value

public function getValueTable($entityName, $valueType)

 

2.7

//* Get connection by name or type

protected function _getConnection($connectionName)

 

2.8

// * Retrieve connection for read data   @return  Zend_Db_Adapter_Abstract

protected function _getReadAdapter()

 

2.9

//* Retrieve connection for read data  @return  Varien_Db_Adapter_Pdo_Mysql

 protected function _getReadAdapter()

 

2.10

Retrieve connection for write data   @return  Varien_Db_Adapter_Pdo_Mysql

protected function _getWriteAdapter()

 

2.11

//Temporary resolving collection compatibility

@return Varien_Db_Adapter_Pdo_Mysql

 public function getReadConnection()

 

2.12

//* Load an object   @return  Mage_Core_Model_Mysql4_Abstract

public function load(Mage_Core_Model_Abstract $object, $value, $field=null)

 

2.13

//Retrieve select object for load object data   @return  Zend_Db_Select

protected function _getLoadSelect($field, $value, $object)

 

2.14

// * Save object object data

@param   Mage_Core_Model_Abstract $object

@return  Mage_Core_Model_Mysql4_Abstract

public function save(Mage_Core_Model_Abstract $object)

 

2.15

//Delete the object

@param Varien_Object $object

@return Mage_Core_Model_Mysql4_Abstract

 public function delete(Mage_Core_Model_Abstract $object)

 

2.16

// * Add unique field restriction

  public function addUniqueField($field)

 

2.17

//* Unserialize serializeable object fields

public function unserializeFields(Mage_Core_Model_Abstract $object)

 

2.18

// Serialize serializeable fields of the object

 protected function _serializeFields(Mage_Core_Model_Abstract $object)

 

2.19

 

2.1

字段序列化

2.2

唯一字段值的一系列操作

2.3

表,id,资源的初始化,以及操作

2.4

读写适配器的得到

2.5

对Mage_Core_Model_Abstract $object的save,delete快速操作。

 

Mage_Core_Model_mysql4_Abstract是数据操作的前序工作的实现,比如得到connection,readAdapter,table等的得到。

 

3

mage_core_model_mysql4_collection_abstract

 

3.1

//* Get Zend_Db_Select instance and applies fields to select if needed     @return Varien_Db_Select

 

public function getSelect()

 

 

3.2

//Retrieve initial fields to select like id field

@return array

protected function _getInitialFieldsToSelect()

 

3.3

 protected function _initInitialFieldsToSelect()

3.4

 public function addFieldToSelect($field, $alias = null)

3.5

  public function removeFieldFromSelect($field, $isAlias = false)

3.6

//* @return Mage_Core_Model_Mysql4_Collection_Abstract

 public function removeAllFieldsFromSelect()

3.7

 Get resource instance

 @return Mage_Core_Model_Mysql4_Abstract

public function getResource()

3.8

 public function getTable($table)

3.9

 //Retrive all ids for collection

 @return array

public function getAllIds()

3.10

 public function join($table, $cond, $cols='*')

3.11

    public function save()

 

3.1

内存方面的操作

3.2

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(abstract------------------------mysql4_abstract--------------mysql4_collection_abstract--------------------内核类的函数分析!!!)