SocialEngine: getDbTable() vs. getItemTable()

血红的双手。 提交于 2019-12-25 02:28:23

问题


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();

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?


回答1:


/application/libraries/Engine/

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

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

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

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



来源:https://stackoverflow.com/questions/52053191/socialengine-getdbtable-vs-getitemtable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!