继承Mage_core_model_mysql4_abstract.php的class
里面的函数操作数据库:
1
查询:
$select = $this->_getReadAdapter()->select()
->from($this->getTable('profile/profile_store'))
->where('profile_id = ?', $object->getId());
$data = $this->_getReadAdapter()->fetchAll($select);
$data是个数组。
2
删除语法例子:
$condition = $this->_getWriteAdapter()->quoteInto('profile_id = ?', $object->getId());
$this->_getWriteAdapter()->delete($this->getTable('profile/profile_store'), $condition);
3
插入数据的例子:
$storeArray = array();
$storeArray['profile_id'] = $object->getId();
$storeArray['store_id'] = $store;
$this->_getWriteAdapter()->insert($this->getTable('profile/profile_store'), $storeArray);
4
重新得到!!select object------>zend_Db_select!!
/**
* Retrieve select object for load object data
*
* @param string $field
* @param mixed $value
* @return Zend_Db_Select
*/
protected function _getLoadSelect($field, $value, $object)
{
$select = parent::_getLoadSelect($field, $value, $object);
if ($object->getStoreId()) {
$select->join(
array('cps' => $this->getTable('profile/profile_store')),
$this->getMainTable().'.profile_id = `cps`.profile_id'
)
->where('is_active=1 AND `cps`.store_id in (' . Mage_Core_Model_App::ADMIN_STORE_ID . ', ?) ',
$object->getStoreId())
->order('store_id DESC')
->limit(1);
}
return $select;
}
************************************************************************************
继承
Mage_Core_Model_Mysql4_Collection_Abstract的类里面的函数操作数据库
collection。
1
$select = $this->getConnection()->select()
->from($this->getTable('profile/profile_store'))
->where($this->getTable('profile/profile_store').'.profile_id IN (?)', $items);
$result = $this->getConnection()->fetchPairs($select)
//
/**
* Fetches all SQL result rows as an array of key-value pairs.
*
* The first column is the key, the second column is the
* value.
*
* @param string|Zend_Db_Select $sql An SQL SELECT statement.
* @param mixed $bind Data to bind into SELECT placeholders.
* @return array
*/
public function fetchPairs($sql, $bind = array()
result为数组。
2
$this->getSelect()->join(
array('store_table' => $this->getTable('profile/profile_store')),
'main_table.profile_id = store_table.profile_id',
array()
)
->where('store_table.store_id in (?)', ($withAdmin ? array(0, $store) : $store))
->group('main_table.profile_id');
通过getSelect()方法:@return Varien_Db_Select
$this->getConnection()->select(),得到的也是Varien_Db_Select
但是getSelect加上了一些数据的初始化过程,故在join这方面的操作,要使用getSelect()得到Varien_db_select方法。
明天研究Mage_core_model_mysql4_abstract和Mage_core_model_mysql4_collection_abstract这两个系统class!!!
分享到:
相关推荐
3D-Mage-Studio.zip,mage studio是一个游戏编辑器,建立在mage引擎之上,嵌入在electron中。mage studio将允许使用webgl轻松开发3d应用程序。,3D建模使用专门的软件来创建物理对象的数字模型。它是3D计算机图形的一...
mage hiding F5 algorithm source code
这是一个基于双目立体视觉的运动对象跟踪项目。
利用经典免疫遗传算法实现单阈值图像的分割。
AVR单片机学习板介绍 AVR MAGE8_128二合一
python库。 资源全名:MAGE_Tab_merger-0.0.4-py3-none-any.whl
法师:: PHP MySQL Admin Panel Generator 也可用于Python: PHP MySQL MySQL管理面板生成器(MAGE),这是一个PHP工具,可帮助您在几秒钟内为任何MySQL数据库创建PHP管理面板。 Mage不是PHPMyAdmin; 它不包含您的...
开源项目-magefile-mage.zip,mage,go的makefile替代品
sprite_character_mage_equipment_avatar_pants.NPK:sprite_character_mage_equipment_avatar_pants.NPK
GML脚本向导是一个工具,可以帮助您生成和修改GML脚本标头,只需填写几个字段即可。 符合用于记录脚本的GM:S 1.4和GMS 2(JSDoc)文档样式。 轻松添加,删除和重新排列参数和其他局部变量。 只需单击一个按钮即可...
sprite_character_mage_effect_quasarexplosion.NPK:sprite_character_mage_effect_quasarexplosion.NPK
Download_tool_IDT_V2.0.0_support_CRC_check
leetcode题库 已归档-后续更新地址: 刷题防止老年痴呆(。^▽^) :man_technologist: 每个人都有一个自己的面试题库吧~ StrayCamel247- 使用手册 代码全部放在文件夹中 "leetcode.workspaceFolder": ...
:mage: Vue 2和3支持并带有完整的树状抖动 :wrench: 轻松自定义您的项目 :fire: 热模块重装就绪 :triangular_ruler: 用打字稿写 设置 使用Vue CLI安装。 (建议使用Vue CLI 4+) vue add import-components ...
按需下载
用Autodesk EAGLE打开
sprite_character_mage_effect_basicelement_pluto.NPK:sprite_character_mage_effect_basicelement_pluto.NPK