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


PHP DBManager::get_columns方法代码示例

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


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

示例1: processUsDollarColumns

 /**
  * processUsDollarColumns
  *
  * automatically update *_usdollar fields for backward compatibility
  * with modules that still use this field. The *_usdollar fields use
  * the base_rate field for the rate calculations.
  *
  * @access protected
  * @param  string    $currencyId
  * @return boolean true on success
  */
 protected function processUsDollarColumns($currencyId)
 {
     // loop through all the tables
     foreach ($this->usDollarColumnDefinitions as $tableName => $tableDefs) {
         $columns = $this->db->get_columns($tableName);
         if (empty($columns)) {
             continue;
         }
         foreach ($tableDefs as $amountColumn => $usDollarColumn) {
             if (empty($columns[$amountColumn]) || empty($columns[$usDollarColumn]) || empty($columns['base_rate'])) {
                 continue;
             }
             if (!$this->doCustomUpdateUsDollarRate($tableName, $usDollarColumn, $amountColumn, $currencyId)) {
                 if (!$this->doUpdateUsDollarRate($tableName, $usDollarColumn, $amountColumn, $currencyId)) {
                     return false;
                 }
             }
         }
     }
     return true;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:32,代码来源:CurrencyRateUpdateAbstract.php

示例2: testRepairTableParamsAddIndex

 public function testRepairTableParamsAddIndex()
 {
     $tableName = 'test1_' . mt_rand();
     $params = array('foo' => array('name' => 'foo', 'type' => 'varchar', 'len' => '255'), 'bar' => array('name' => 'bar', 'type' => 'int'));
     $index = array('name' => 'test_index', 'type' => 'index', 'fields' => array('foo', 'bar', 'bazz'));
     if ($this->_db->tableExists($tableName)) {
         $this->_db->dropTableName($tableName);
     }
     $this->createTableParams($tableName, $params, array());
     $params['bazz'] = array('name' => 'bazz', 'type' => 'int');
     $repair = $this->_db->repairTableParams($tableName, $params, array($index), false);
     $this->assertRegExp('#MISSING IN DATABASE.*bazz#i', $repair);
     $this->assertRegExp('#MISSING INDEX IN DATABASE.*test_index#i', $repair);
     $repair = $this->_db->repairTableParams($tableName, $params, array($index), true);
     $idx = $this->_db->get_indices($tableName);
     $this->assertArrayHasKey('test_index', $idx);
     $this->assertContains('foo', $idx['test_index']['fields']);
     $this->assertContains('bazz', $idx['test_index']['fields']);
     $cols = $this->_db->get_columns($tableName);
     $this->assertArrayHasKey('bazz', $cols);
     $this->assertEquals('bazz', $cols['bazz']['name']);
     $this->assertEquals($this->_db->getColumnType('int'), $cols['bazz']['type']);
     $this->dropTableName($tableName);
 }
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:24,代码来源:DBManagerTest.php

示例3: array


//.........这里部分代码省略.........
             $this->register_field_for_query($display_column);
             // this hack is so that the id field for every table is always selected
             if (empty($display_column['table_key'])) {
                 $this->handleException('table_key doesnt exist for ' . $display_column['name']);
             }
             if ($display_column['type'] == 'fullname') {
                 $name = "{$key}_{$display_column['name']}";
                 $this->report_def[$name] = $this->createNameList($display_column['table_key']);
                 $this->create_select($name, $field_list_name);
                 continue;
             }
             if (empty($got_join[$display_column['table_key']])) {
                 $id_column = array();
                 $got_join[$display_column['table_key']] = 1;
                 if (!empty($display_column['column_key']) && !empty($this->all_fields[$display_column['column_key']]) && !empty($this->all_fields[$display_column['column_key']]['custom_type'])) {
                     $do_id = 0;
                 } else {
                     $do_id = 1;
                 }
                 // Bug 45019: don't add ID column if this column is the ID column
                 // PAT-1008: add id column to select for summation query to make name column linkable
                 if ($field_list_name != 'total_select_fields' && ($field_list_name != 'summary_select_fields' || $display_column['type'] == 'name') && $do_id) {
                     $id_column['name'] = 'id';
                     $id_column['type'] = 'id';
                     $id_column['table_key'] = $display_column['table_key'];
                     if (preg_match('/_cstm/', $display_column['table_alias']) > 0) {
                         // bug #49475
                         $id_column['table_alias'] = $this->focus->table_name;
                     } else {
                         $id_column['table_alias'] = $display_column['table_alias'];
                     }
                     $id_column['column_key'] = $id_column['table_key'] . ':' . $id_column['name'];
                     $select_piece = $this->layout_manager->widgetQuery($id_column);
                     if (!$this->select_already_defined($select_piece, $field_list_name)) {
                         array_push($this->{$field_list_name}, $select_piece);
                         // PAT-1008: add id column to group by since it's added to select for summation query. Required by non-mysql dbs
                         if ($field_list_name == 'summary_select_fields') {
                             $this->layout_manager->setAttribute('context', 'GroupBy');
                             $this->group_by_arr[] = $this->layout_manager->widgetQuery($id_column);
                             $this->layout_manager->setAttribute('context', 'Select');
                         }
                     }
                 }
             }
             // specify "currency_alias" parameter for fields of currency type
             if (!empty($display_column['column_key']) && !empty($this->all_fields[$display_column['column_key']]) && $display_column['type'] == 'currency') {
                 $field_def = $this->all_fields[$display_column['column_key']];
                 if (strpos($field_def['name'], '_usdoll') === false) {
                     $display_column['currency_alias'] = $display_column['table_alias'] . '_currencies';
                 }
             }
             $select_piece = $this->layout_manager->widgetQuery($display_column);
         }
         // Bug 40573: addon field for "day" "select" field
         if (isset($display_column['column_function']) && $display_column['column_function'] == 'day') {
             $addon_dispay_column = $display_column;
             $addon_dispay_column['column_function'] = 'dayreal';
             $addon_select_piece = $this->layout_manager->widgetQuery($addon_dispay_column);
             if (!$this->select_already_defined($addon_select_piece, $field_list_name)) {
                 array_push($this->{$field_list_name}, $addon_select_piece);
             }
         }
         if (!$this->select_already_defined($select_piece, $field_list_name)) {
             array_push($this->{$field_list_name}, $select_piece);
         }
         if (!empty($display_column['column_key']) && !empty($this->all_fields[$display_column['column_key']])) {
             $field_def = $this->all_fields[$display_column['column_key']];
             if (!empty($field_def['ext2'])) {
                 $select_piece = $this->getExt2FieldDefSelectPiece($field_def);
                 array_push($this->{$field_list_name}, $select_piece);
             }
         }
         // for SUM currency fields add params to join 'currencies' table
         if (!empty($display_column['column_key']) && !empty($this->all_fields[$display_column['column_key']]) && !empty($display_column['group_function']) && isset($display_column['field_type']) && $display_column['field_type'] == 'currency' && strpos($display_column['name'], '_usdoll') === false && isset($display_column['currency_alias']) && !isset($this->currency_join[$key][$display_column['currency_alias']])) {
             $table_key = $this->full_bean_list[$display_column['table_key']]->table_name;
             $bean_table_alias = $display_column['table_key'] === 'self' ? $table_key : $this->getRelatedAliasName($display_column['table_key']);
             // by default, currency table is joined to the alias of primary table
             $table_alias = $bean_table_alias;
             // but if the field is contained in a custom table, use it's alias for join
             $field_def = $this->all_fields[$display_column['column_key']];
             if ($field_def['real_table'] != $table_key) {
                 $columns = $this->db->get_columns($field_def['real_table']);
                 if (isset($columns['currency_id'])) {
                     $table_alias = $display_column['table_alias'];
                 }
             }
             // create additional join of currency table for each module containing currency fields
             $this->currency_join[$key][$display_column['currency_alias']] = $table_alias;
         }
     }
     // 'register' the joins for the other column defs since we need to join all for summary to work.. else the count and maybe other group functions won't work.
     if ($key == 'display_columns') {
         $key = 'summary_columns';
     } else {
         $key = 'display_columns';
     }
     if ($got_count == 0 && $field_list_name == 'summary_select_fields') {
         array_push($this->{$field_list_name}, 'count(*) count');
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:101,代码来源:Report.php


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