如何转储 SuiteCRM $bean

How to dump SuiteCRM $bean

我是 suitecrm 的新手。我需要使用逻辑挂钩连接到外部数据库。 我的第一个想法是查看触发事件时 $bean 变量中有哪些可用数据。所以我放了一个

class testAccount_class
{
        function testingAccount($bean, $event, $arguments)
        {
                #$bean->first_name=strtoupper($bean->first_name);
                error_log("Account Before Save\nBean:\n" . print_r($bean, TRUE));                
                error_log("====================================\n");
        }
}
 

在挂钩 class 文件中。但是我在转储中看到的是:

Account Before Save
Bean:
Account Object
(
    [field_name_map] => Array
        (
            [id] => Array
                (
                    [name] => id
                    [vname] => LBL_ID
                    [type] => id
                    [required] => 1
                    [reportable] => 1
                    [comment] => Unique identifier
                    [inline_edit] => 
                )

            [name] => Array
                (
                    [name] => name
                    [type] => name
                    [dbType] => varchar
                    [vname] => LBL_NAME
                    [len] => 150
                    [comment] => Name of the Company
                    [unified_search] => 1
                    [full_text_search] => Array
                        (
                            [boost] => 3
                        )

                    [audited] => 1
                    [required] => 1
                    [importable] => required
                    [merge_filter] => selected
                )

            [date_entered] => Array
                (
                    [name] => date_entered
                    [vname] => LBL_DATE_ENTERED
                    [type] => datetime
                    [group] => created_by_name
                    [comment] => Date record created
                    [enable_range_search] => 1
                    [options] => date_range_search_dom
                    [inline_edit] => 
                )
..... cut off the rest ....

我没有看到预期的任何记录数据。我在这里做错了什么?我是否需要调用其他方法来实际获取数据?

谢谢,

这是正确的做法,一些注意事项

  1. $bean->id新建记录时为空
  2. 确保您阅读所有 print_r 输出,它非常广泛但包含您要查找的数据。
  3. $bean->column_fields returns 一个包含 bean 字段的数组,您可以使用该数组来访问数据,例如 $bean->$column_field_item