SocialEngine:getDbTable()与getItemTable() [英] SocialEngine: getDbTable() vs. getItemTable()

查看:91
本文介绍了SocialEngine:getDbTable()与getItemTable()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常看到使用Engine_Api::_()->getDbTable()在SocialEngine中检索表.
例如:

I have often seen tables are retrieved in SocialEngine using Engine_Api::_()->getDbTable().
For example:

$usersTbl = Engine_Api::_()->getDbTable('users','user');
$row = $usersTbl->createRow();
$row->user_id = $user->getIdentity();
$row->phone_number = $phoneNumber;
$row->save();

但是,我也看到SocialEngine在很多地方都使用过Engine_Api::_()->getItemTable.例如:

However, I also see that SocialEngine has used Engine_Api::_()->getItemTable in many places. For example:

$table = Engine_Api::_()->getItemTable($type);
$row = $table->createRow();
foreach($params as $key=>$value) {
 if(isset($row->$key)) {
   $row->key = $value;
 }
}
$row->save();

这两种访问方式(如果有)的主要区别是什么?何时使用每种访问方式?

What is the main difference between these two types of accesses, if any, and when is each one used?

推荐答案

/application/libraries/Engine/

Engine文件夹是zend之上的SocialEngine CMS,在这里您可以找到所有功能定义

Engine folder is SocialEngine CMS on top of zend, here you find all the function definitions

/application/modules/moduleName/settings/manifest.php [您在此处在模块中添加项目]

/application/modules/moduleName/settings/manifest.php [Here you add items, in a module]

在加载应用程序时,将扫描所有清单文件并加载项目. getItemTable仅在定义项时才能加载DbTable类.

when application is loaded, all manifest files are scanned and items are loaded. getItemTable can only load, DbTable class when item is defined.

其中getDbTable()可以用于不用作Items的表.

where as getDbTable() can be used for tables which are not used as Items.

这篇关于SocialEngine:getDbTable()与getItemTable()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆