当前位置: 首页>>代码示例>>PHP>>正文


PHP SugarBean::getFieldDefinitions方法代码示例

本文整理汇总了PHP中SugarBean::getFieldDefinitions方法的典型用法代码示例。如果您正苦于以下问题:PHP SugarBean::getFieldDefinitions方法的具体用法?PHP SugarBean::getFieldDefinitions怎么用?PHP SugarBean::getFieldDefinitions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SugarBean的用法示例。


在下文中一共展示了SugarBean::getFieldDefinitions方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getIndexVardefs

 /**
  * Returns an array of indices for the current module
  *
  * @return array
  */
 private function _getIndexVardefs()
 {
     $indexes = $this->_focus->getIndices();
     //grab any custom indexes if they exist
     if ($this->_focus->hasCustomFields()) {
         $custmIndexes = $this->_focus->db->helper->get_indices($this->_focus->table_name . '_cstm');
         $indexes = array_merge($custmIndexes, $indexes);
     }
     // remove any that are datetime or time field as we can't dupe check them correctly since we don't export
     // seconds
     $fields = $this->_focus->getFieldDefinitions();
     foreach ($indexes as $key => $index) {
         foreach ($index['fields'] as $field) {
             if (isset($fields[$field]) && ($fields[$field]['type'] == 'datetime' || $fields[$field]['type'] == 'datetimecombo' || $fields[$field]['type'] == 'time')) {
                 unset($indexes[$key]);
                 break 1;
             }
         }
     }
     if ($this->_focus->getFieldDefinition('email1')) {
         $indexes[] = array('name' => 'special_idx_email1', 'type' => 'index', 'fields' => array('email1'));
     }
     if ($this->_focus->getFieldDefinition('email2')) {
         $indexes[] = array('name' => 'special_idx_email2', 'type' => 'index', 'fields' => array('email2'));
     }
     return $indexes;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:32,代码来源:ImportDuplicateCheck.php

示例2: createTableSQL

 /**
  * @see DBHelper::createTableSQL()
  */
 public function createTableSQL(SugarBean $bean)
 {
     $tablename = $bean->getTableName();
     $fieldDefs = $bean->getFieldDefinitions();
     $indices = $bean->getIndices();
     $engine = $this->getEngine($bean);
     return $this->createTableSQLParams($tablename, $fieldDefs, $indices, $engine);
 }
开发者ID:aldridged,项目名称:gtg-sugar,代码行数:11,代码来源:MysqlHelper.php

示例3: updateSQL

 /**
  * Generates SQL for update statement.
  *
  * @param  SugarBean $bean SugarBean instance
  * @param  array  $where Optional, where conditions in an array
  * @return string SQL Create Table statement
  */
 public function updateSQL(SugarBean $bean, array $where = array())
 {
     $primaryField = $bean->getPrimaryFieldDefinition();
     $columns = array();
     $fields = $bean->getFieldDefinitions();
     // get column names and values
     foreach ($fields as $field => $fieldDef) {
         if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') {
             continue;
         }
         // Do not write out the id field on the update statement.
         // We are not allowed to change ids.
         if ($fieldDef['name'] == $primaryField['name']) {
             continue;
         }
         // If the field is an auto_increment field, then we shouldn't be setting it.  This was added
         // specially for Bugs and Cases which have a number associated with them.
         if (!empty($bean->field_name_map[$field]['auto_increment'])) {
             continue;
         }
         //custom fields handle their save separately
         if (isset($bean->field_name_map) && !empty($bean->field_name_map[$field]['custom_type'])) {
             continue;
         }
         // no need to clear deleted since we only update not deleted records anyway
         if ($fieldDef['name'] == 'deleted' && empty($bean->deleted)) {
             continue;
         }
         if (isset($bean->{$field})) {
             $val = from_html($bean->{$field});
         } else {
             continue;
         }
         if (!empty($fieldDef['type']) && $fieldDef['type'] == 'bool') {
             $val = $bean->getFieldValue($field);
         }
         if (strlen($val) == 0) {
             if (isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) {
                 $val = $fieldDef['default'];
             } else {
                 $val = null;
             }
         }
         if (!empty($val) && !empty($fieldDef['len']) && strlen($val) > $fieldDef['len']) {
             $val = $this->truncate($val, $fieldDef['len']);
         }
         if (!is_null($val) || !empty($fieldDef['required'])) {
             $columns[] = "{$fieldDef['name']}=" . $this->massageValue($val, $fieldDef);
         } elseif ($this->isNullable($fieldDef)) {
             $columns[] = "{$fieldDef['name']}=NULL";
         } else {
             $columns[] = "{$fieldDef['name']}=" . $this->emptyValue($fieldDef['type']);
         }
     }
     if (sizeof($columns) == 0) {
         return "";
     }
     // no columns set
     // build where clause
     $where = $this->getWhereClause($bean, $this->updateWhereArray($bean, $where));
     if (isset($fields['deleted'])) {
         $where .= " AND deleted=0";
     }
     return "UPDATE " . $bean->getTableName() . "\n\t\t\t\t\tSET " . implode(",", $columns) . "\n\t\t\t\t\t{$where}";
 }
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:72,代码来源:DBManager.php

示例4: updateSQL

 /**
  * Generates SQL for update statement.
  *
  * @param  object $bean SugarBean instance
  * @param  array  $where Optional, where conditions in an array
  * @return string SQL Create Table statement
  */
 public function updateSQL(SugarBean $bean, array $where = array())
 {
     $primaryField = $bean->getPrimaryFieldDefinition();
     $columns = array();
     // get column names and values
     foreach ($bean->getFieldDefinitions() as $field => $fieldDef) {
         // Do not write out the id field on the update statement.
         // We are not allowed to change ids.
         if ($fieldDef['name'] == $primaryField['name']) {
             continue;
         }
         // If the field is an auto_increment field, then we shouldn't be setting it.  This was added
         // specially for Bugs and Cases which have a number associated with them.
         if (isset($bean->field_name_map[$field]['auto_increment']) && $bean->field_name_map[$field]['auto_increment'] == true) {
             continue;
         }
         //custom fields handle their save seperatley
         if (isset($bean->field_name_map) && !empty($bean->field_name_map[$field]['custom_type'])) {
             continue;
         }
         if (isset($bean->{$fieldDef}['name']) && (!isset($fieldDef['source']) || $fieldDef['source'] == 'db')) {
             $val = $bean->getFieldValue($fieldDef['name']);
             // clean the incoming value..
             $val = from_html($val);
             // need to do some thing about types of values
             if (strlen($val) <= 0) {
                 $columns[] = "{$fieldDef['name']}=null";
             } else {
                 $columns[] = "{$fieldDef['name']}=" . $this->massageValue($val, $fieldDef);
             }
         }
     }
     if (sizeof($columns) == 0) {
         return "";
     }
     // no columns set
     // build where clause
     $where = $this->updateWhereArray($bean, $where);
     $where = $this->getWhereClause($bean, $where);
     return "update " . $bean->getTableName() . "\n                    set " . implode(",", $columns) . "\n                    {$where} and deleted=0";
 }
开发者ID:rgauss,项目名称:sugarcrm_dev,代码行数:48,代码来源:DBHelper.php

示例5: generateInsertSQL

 /**
  * Generate a set of Insert statements based on the bean given
  *
  * @deprecated
  *
  * @param  object $bean         the bean from which table we will generate insert stmts
  * @param  string $select_query the query which will give us the set of objects we want to place into our insert statement
  * @param  int    $start        the first row to query
  * @param  int    $count        the number of rows to query
  * @param  string $table        the table to query from
  * @param  string $db_type      the client db type
  * @return string SQL insert statement
  */
 public function generateInsertSQL(SugarBean $bean, $select_query, $start, $count = -1, $table, $db_type, $is_related_query = false)
 {
     $GLOBALS['log']->info('call to DBManager::generateInsertSQL() is deprecated');
     global $sugar_config;
     $count_query = $bean->create_list_count_query($select_query);
     if (!empty($count_query)) {
         // We have a count query.  Run it and get the results.
         $result = $this->query($count_query, true, "Error running count query for {$this->object_name} List: ");
         $assoc = $this->fetchByAssoc($result);
         if (!empty($assoc['c'])) {
             $rows_found = $assoc['c'];
         }
     }
     if ($count == -1) {
         $count = $sugar_config['list_max_entries_per_page'];
     }
     $next_offset = $start + $count;
     $result = $this->limitQuery($select_query, $start, $count);
     $row_count = $this->getRowCount($result);
     // get basic insert
     $sql = "INSERT INTO " . $table;
     $custom_sql = "INSERT INTO " . $table . "_cstm";
     // get field definitions
     $fields = $bean->getFieldDefinitions();
     $custom_fields = array();
     if ($bean->hasCustomFields()) {
         foreach ($fields as $fieldDef) {
             if ($fieldDef['source'] == 'custom_fields') {
                 $custom_fields[$fieldDef['name']] = $fieldDef['name'];
             }
         }
         if (!empty($custom_fields)) {
             $custom_fields['id_c'] = 'id_c';
             $id_field = array('name' => 'id_c', custom_type => 'id');
             $fields[] = $id_field;
         }
     }
     // get column names and values
     $row_array = array();
     $columns = array();
     $cstm_row_array = array();
     $cstm_columns = array();
     $built_columns = false;
     //configure client helper
     $dbHelper = $this->configureHelper($db_type);
     while (($row = $this->fetchByAssoc($result)) != null) {
         $values = array();
         $cstm_values = array();
         if (!$is_related_query) {
             foreach ($fields as $fieldDef) {
                 if (isset($fieldDef['source']) && $fieldDef['source'] != 'db' && $fieldDef['source'] != 'custom_fields') {
                     continue;
                 }
                 $val = $row[$fieldDef['name']];
                 //handle auto increment values here only need to do this on insert not create
                 if ($fieldDef['name'] == 'deleted') {
                     $values['deleted'] = $val;
                     if (!$built_columns) {
                         $columns[] = 'deleted';
                     }
                 } else {
                     $type = $fieldDef['type'];
                     if (!empty($fieldDef['custom_type'])) {
                         $type = $fieldDef['custom_type'];
                     }
                     // need to do some thing about types of values
                     if ($db_type == 'mysql' && $val == '' && ($type == 'datetime' || $type == 'date' || $type == 'int' || $type == 'currency' || $type == 'decimal')) {
                         if (!empty($custom_fields[$fieldDef['name']])) {
                             $cstm_values[$fieldDef['name']] = 'null';
                         } else {
                             $values[$fieldDef['name']] = 'null';
                         }
                     } else {
                         if (isset($type) && $type == 'int') {
                             if (!empty($custom_fields[$fieldDef['name']])) {
                                 $cstm_values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val));
                             } else {
                                 $values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val));
                             }
                         } else {
                             if (!empty($custom_fields[$fieldDef['name']])) {
                                 $cstm_values[$fieldDef['name']] = "'" . $GLOBALS['db']->quote(from_html($val)) . "'";
                             } else {
                                 $values[$fieldDef['name']] = "'" . $GLOBALS['db']->quote(from_html($val)) . "'";
                             }
                         }
                     }
//.........这里部分代码省略.........
开发者ID:razorinc,项目名称:sugarcrm-example,代码行数:101,代码来源:DBManager.php

示例6: array

 function set_relationships(SugarBean $record, SugarBean $bean, $params = array())
 {
     $record_vardefs = $record->getFieldDefinitions();
     require_once 'modules/Relationships/Relationship.php';
     if (isset($params['rel'])) {
         foreach ($params['rel'] as $key => $field) {
             if ($field == '' || $params['rel_value'][$key] == '') {
                 continue;
             }
             switch ($params['rel_value_type'][$key]) {
                 case 'Field':
                     $data = $bean->field_defs[$params['rel_value'][$key]];
                     if ($data['type'] == 'relate' && isset($data['id_name'])) {
                         $params['rel_value'][$key] = $data['id_name'];
                     }
                     $rel_id = $bean->{$params}['rel_value'][$key];
                     break;
                 default:
                     $rel_id = $params['rel_value'][$key];
                     break;
             }
             $def = $record_vardefs[$field];
             if ($def['type'] == 'link' && !empty($def['relationship'])) {
                 $record->load_relationship($field);
                 $record->{$field}->add($rel_id);
             }
         }
     }
 }
开发者ID:omusico,项目名称:windcrm,代码行数:29,代码来源:actionCreateRecord.php

示例7: getBeanDefs

 /**
  * Return field definitions of a bean.
  * Need for covering class by test.
  * @param SugarBean $bean
  * @return array
  */
 protected function getBeanDefs($bean)
 {
     return $bean->getFieldDefinitions();
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:10,代码来源:4_ClearSubpanels.php

示例8: updateSQL

 /**
  * Generates SQL for update statement.
  *
  * @param  SugarBean $bean SugarBean instance
  * @param  array  $where Optional, where conditions in an array
  * @return string SQL Create Table statement
  */
 public function updateSQL(SugarBean $bean, array $where = array(), $usePreparedStatements = false)
 {
     $dataFields = array();
     $dataValues = array();
     $primaryField = $bean->getPrimaryFieldDefinition();
     $fields = $bean->getFieldDefinitions();
     // get column names and values
     foreach ($fields as $field => $fieldDef) {
         if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') {
             continue;
         }
         // Do not write out the id field on the update statement.
         // We are not allowed to change ids.
         if ($fieldDef['name'] == $primaryField['name']) {
             continue;
         }
         // If the field is an auto_increment field, then we shouldn't be setting it.  This was added
         // specially for Bugs and Cases which have a number associated with them.
         if (!empty($bean->field_name_map[$field]['auto_increment'])) {
             continue;
         }
         //custom fields handle their save separately
         if (isset($bean->field_name_map) && !empty($bean->field_name_map[$field]['custom_type'])) {
             continue;
         }
         // no need to clear deleted since we only update not deleted records anyway
         if ($fieldDef['name'] == 'deleted' && empty($bean->deleted)) {
             continue;
         }
         if (!isset($bean->{$field})) {
             continue;
         }
         $dataValues[$field] = $bean->{$field};
         $dataFields[$field] = $fieldDef;
     }
     if (empty($dataValues)) {
         return "";
         // no columns set
     }
     // build where clause
     $where_data = $this->updateWhereArray($bean, $where, $usePreparedStatements);
     if (isset($fields['deleted'])) {
         $where_data['deleted'] = "0";
     }
     foreach ($where_data as $field => $value) {
         $dataFields[$field] = $fields[$field];
     }
     return $this->updateParams($bean->getTableName(), $dataFields, $dataValues, $where_data, null, false, $usePreparedStatements);
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:56,代码来源:DBManager.php

示例9: getRelatedRecordArguments

 /**
  * Returns arguments for RelateRecordApi for the given action
  *
  * @param SugarBean $bean Primary bean
  * @param array $args This API arguments
  * @param string $action Related record action.
  *
  * @return array
  * @throws SugarApiExceptionInvalidParameter
  */
 protected function getRelatedRecordArguments(SugarBean $bean, array $args, $action)
 {
     $arguments = array();
     foreach ($bean->getFieldDefinitions() as $field => $definition) {
         if (!isset($definition['type']) || $definition['type'] != 'link') {
             continue;
         }
         if (!isset($args[$field])) {
             continue;
         }
         if (!is_array($args[$field])) {
             throw new SugarApiExceptionInvalidParameter(sprintf('Link field must contain array of actions, %s given', gettype($field)));
         }
         if (!isset($args[$field][$action])) {
             continue;
         }
         $data = $args[$field][$action];
         if (!is_array($data)) {
             throw new SugarApiExceptionInvalidParameter(sprintf('Link action data must be array, %s given', gettype($data)));
         }
         $arguments[$field] = $data;
     }
     return $arguments;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:34,代码来源:ModuleApi.php

示例10: getDefinition

 /**
  * Get fields definition object for a $seed.
  * @param SugarBean $seed
  * @return DefinitionObject
  */
 protected function getDefinition($seed)
 {
     return new DefinitionObject($seed->getFieldDefinitions());
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:9,代码来源:1_ClearVarDefs.php


注:本文中的SugarBean::getFieldDefinitions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。