Sugarcrm支持产品指南糖开发人员糖开发人员指南11.0数据框架楷模Beanfactory.

Beanfactory.

概述

The BeanFactory class, located in ./data/BeanFactory.php, is used for loading an instance of a 。应在您创建或检索bean对象的任何时间使用此类。它将自动处理bean所需的任何类。

创建糖果对象

newbean()

To create a new, empty SugarBean, use the newbean() method. This method is typically used when creating a new record for a module or to call properties of the module's bean object.

$bean = BeanFactory::newBean($module);

newbeanbyname()

用于通过beanlist名称获取bean。

$bean = BeanFactory::newBeanByName($name);

检索糖食物体

getBean()

GetBean()方法可用于从数据库中检索特定记录。如果未通过记录ID,则将创建一个新的bean对象。

$bean = BeanFactory::getBean($module, $record_id);

笔记:禁用行级安全性时,才应将BEAN的访问才会设置为TRUE,例如在从自定义入口点更新引线记录时,才会设置为true。在绕过行安全时访问bean的示例是:

$bean = BeanFactory::getBean($module, $record_id, array('disable_row_level_security' => true));

检索方()

The 检索方() method can also be used to retrieve a specific record from the database. The difference between this method and getBean() is that null will be returned instead of an empty bean object if the retrieve fails.

$bean = BeanFactory::retrieveBean($module, $record_id);

笔记:禁用行级安全性在访问bean时,才应将其设置为true,例如,当从自定义入口点更新引线记录时,才会设置为true。在绕过行安全时访问bean的示例是:

$bean = BeanFactory::retrieveBean($module, $record_id, array('disable_row_level_security' => true));

检索模块键

getobjectname()

The getobjectname() method will return the object name / dictionary key for a given module. This is normally the same as the bean name, but may not be for some modules such as Cases which has a key of 'aCase' and a name of 'Case'.

$moduleKey = BeanFactory::getObjectName($moduleName);

getbeanname()

The getbeanname() method will retrieve the bean class name given a module name.

$moduleClass = BeanFactory::getBeanName($module);

 

最后修改:2021-02-17 02:44:13