model
不是eav模型的初始化。
1
class RichardMason_Profile_Model_Profile extends Mage_Core_Model_Abstract{
public function _construct()
{
parent::_construct();
$this->_init('profile/profile');
}
1.1
parent::parent为空;
1.2
//abstract class Mage_Core_Model_Abstract extends Varien_Object
/**
* Standard model initialization
*
* @param string $resourceModel
* @param string $idFieldName
* @return Mage_Core_Model_Abstract
*/
protected function _init($resourceModel)
{
$this->_setResourceModel($resourceModel);
}
1.2.1
//abstract class Mage_Core_Model_Abstract extends Varien_Object
/**
* Set resource names
*
* If collection name is ommited, resource name will be used with _collection appended
*
* @param string $resourceName
* @param string|null $resourceCollectionName
*/
protected function _setResourceModel($resourceName, $resourceCollectionName=null)
{
$this->_resourceName = $resourceName;
if (is_null($resourceCollectionName)) {
$resourceCollectionName = $resourceName.'_collection';
}
$this->_resourceCollectionName = $resourceCollectionName;
}
故可以看出Model/profile.php的初始化执行init方法,是一个赋值的过程。
将变量$_moduleName赋值为profile/profile,$_resourceCollectionName赋值为
profile/profile_collection。
1>对于$_resourceName,文件路径设定在config.xml中,
<profile_mysql4>
<class>RichardMason_Profile_Model_Mysql4</class>
2>$_resourceCollectionName,设定在本函数的传入参数:$resourceCollectionName,如果为空,则使
用默认规则。 $resourceCollectionName = $resourceName.'_collection'
2
model/mysql4/profile.php
初始化:
public function _construct()
{
// Note that the profiles_id refers to the key field in your database table.
$this->_init('profile/profile', 'profile_id');
}
2.1
//abstract class Mage_Core_Model_Mysql4_Abstract extends Mage_Core_Model_Resource_Abstract
/**
* Standard resource model initialization
*
* @param string $mainTable
* @param string $idFieldName
* @return Mage_Core_Model_Mysql4_Abstract
*/
protected function _init($mainTable, $idFieldName)
{
$this->_setMainTable($mainTable, $idFieldName);
}
2.2
//abstract class Mage_Core_Model_Mysql4_Abstract extends Mage_Core_Model_Resource_Abstract
/**
* Set main entity table name and primary key field name
*
* If field name is ommited {table_name}_id will be used
*
* @param string $mainTable
* @param string|null $idFieldName
* @return Mage_Core_Model_Mysql4_Abstract
*/
protected function _setMainTable($mainTable, $idFieldName=null)
{
$mainTableArr = explode('/', $mainTable);
if (!empty($mainTableArr[1])) {
if (empty($this->_resourceModel)) {
$this->_setResource($mainTableArr[0]);
}
$this->_setMainTable($mainTableArr[1], $idFieldName);
} else {
$this->_mainTable = $mainTable;
if (is_null($idFieldName)) {
$idFieldName = $mainTable.'_id';
}
$this->_idFieldName = $idFieldName;
}
return $this;
}
为表,id赋值的过程。
2.2.1
/**
* Resource model name that contains entities (names of tables)
*
* @var string
*/
protected $_resourceModel;
$this->_mainTable为最后那个反斜杠后面的字符,id为$idFieldName
3
class RichardMason_Profile_Model_Mysql4_Profile_Collection extends
Mage_Core_Model_Mysql4_Collection_Abstract
public function _construct()
{
parent::_construct();
$this->_init('profile/profile');
$this->_map['fields']['profile_id'] = 'main_table.profile_id';
}
3.1
$this->_init('profile/profile');
//abstract class Mage_Core_Model_Mysql4_Collection_Abstract extends
Varien_Data_Collection_Db
/**
* Standard resource collection initalization
*
* @param string $model
* @return Mage_Core_Model_Mysql4_Collection_Abstract
*/
protected function _init($model, $resourceModel=null)
{
$this->setModel($model);
if (is_null($resourceModel)) {
$resourceModel = $model;
}
$this->setResourceModel($resourceModel);
return $this;
}
3.1.1
//$this->_model =profile
$this->_itemObjectClass的赋值
$this->setModel($model);
/**
* Set model name for collection items
*
* @param string $model
* @return Mage_Core_Model_Mysql4_Collection_Abstract
*/
public function setModel($model)
{
if (is_string($model)) {
$this->_model = $model;
$this->setItemObjectClass(Mage::getConfig()->getModelClassName($model));
}
return $this;
}
3.1.1.1
/**
* Set collection item class name
*
* @param string $className
* @return Varien_Data_Collection
*/
function setItemObjectClass($className)
{
$className = Mage::getConfig()->getModelClassName($className);
/**
* is_subclass_of($className, 'Varien_Object') - Segmentation fault in php 5.2.3
*/
/*if (!is_subclass_of($className, 'Varien_Object')) {
throw new Exception($className.' does not extends from Varien_Object');
}*/
$this->_itemObjectClass = $className;
return $this;
}
3.1.2
$this->setResourceModel($resourceModel);
public function setResourceModel($model)
{
$this->_resourceModel = $model;
}
分享到:
相关推荐
赠送jar包:activiti-bpmn-model-5.21.0.jar; 赠送原API文档:activiti-bpmn-model-5.21.0-javadoc.jar; 赠送源代码:activiti-bpmn-model-5.21.0-sources.jar; 赠送Maven依赖信息文件:activiti-bpmn-model-...
Qwen2-7B 的 model-00001-of-00004.safetensors 的2/2
api-ms-win-appmodel-runtime-l1-1-0.dll下载,想要的同学可以下载
Qwen2-7B 的 model-00001-of-00004.safetensors 的1/2
meta-llama-3-8b-instruct 的 model-00001-of-00004.safetensors 的1/3
Qwen2-7B Base 的 model-00003-of-00004.safetensors 的1/2
总之,GI-Model-Importer为原神玩家提供了一种个性化游戏体验的方式,通过它,玩家可以将自己的创意和想象力融入到游戏中,创造出独特的角色和场景。但同时,也需谨慎对待这种修改行为,以避免潜在的问题和风险。
- **初始化配置**:在项目初始化时,通过`createPersistor`函数配置持久化策略,包括选择存储器(localStorage或sessionStorage),定义需要持久化的model,以及设置黑/白名单等。 - **reducer处理**:`...
meta-llama-3-8b-instruct 的 model-00001-of-00004.safetensors 的3/3
https://github.com/AUTOMATIC1111/TorchDeepDanbooru/releases/download/v1/model-resnet_custom_v3.pt
MVC-ListView-DataModel-master.zipMVC-ListView-DataModel-master.zipMVC-ListView-DataModel-master.zipMVC-ListView-DataModel-master.zipMVC-ListView-DataModel-master.zipMVC-ListView-DataModel-master....
Qwen2-7B-Instruct 的 model-00001-of-00004.safetensors 的2/2
meta-llama-3-8b-instruct 的 model-00004-of-00004.safetensors
Qwen2-7B 的 model-00002-of-00004.safetensors 的2/2
资源分类:Python库 所属语言:Python 资源全名:datamodel-code-generator-0.6.17.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
1. **初始化模型参数**:首先选择一组初始参数。 2. **任务采样**:从一系列预定义的任务中随机选取一批任务作为训练任务。 3. **内循环(内层优化)**:对于每个任务,使用梯度下降法更新模型参数。这一过程模拟了...
赠送jar包:activiti-bpmn-model-5.21.0.jar; 赠送原API文档:activiti-bpmn-model-5.21.0-javadoc.jar; 赠送源代码:activiti-bpmn-model-5.21.0-sources.jar; 赠送Maven依赖信息文件:activiti-bpmn-model-...
在数据可视化方面,`model-viewer`虽然不直接处理图表,但它可以与其他数据可视化库结合,将3D模型与动态数据关联起来,创建出更直观、更生动的信息展示。 【子文件名列表】:GoogleWebComponents-model-viewer-f...
maven-model-builder-3.6.3.jar
Qwen2-7B 的 model-00004-of-00004.safetensors 的1/2