Exemplo n.º 1
0
 /**
  * Implements repair of a db table for a bean.
  *
  * @param  SugarBean $bean    SugarBean instance
  * @param  bool   $execute true if we want the action to take place, false if we just want the sql returned
  * @return string SQL statement or empty string, depending upon $execute
  */
 public function repairTable(SugarBean $bean, $execute = true)
 {
     $indices = $bean->getIndices();
     $fielddefs = $bean->getFieldDefinitions();
     $tablename = $bean->getTableName();
     //Clean the indexes to prevent duplicate definitions
     $new_index = array();
     foreach ($indices as $ind_def) {
         $new_index[$ind_def['name']] = $ind_def;
     }
     //jc: added this for beans that do not actually have a table, namely
     //ForecastOpportunities
     if ($tablename == 'does_not_exist' || $tablename == '') {
         return '';
     }
     global $dictionary;
     $engine = null;
     if (isset($dictionary[$bean->getObjectName()]['engine']) && !empty($dictionary[$bean->getObjectName()]['engine'])) {
         $engine = $dictionary[$bean->getObjectName()]['engine'];
     }
     return $this->repairTableParams($tablename, $fielddefs, $new_index, $execute, $engine);
 }
Exemplo n.º 2
0
 /**
  * Implements repair of a db table for a bean.
  *
  * @param  object $bean    SugarBean instance
  * @param  bool   $execute true if we want the action to take place, false if we just want the sql returned
  * @return string SQL statement or empty string, depending upon $execute
  */
 public function repairTable(SugarBean $bean, $execute = true)
 {
     $indices = $bean->getIndices();
     $fielddefs = $bean->getFieldDefinitions();
     $tablename = $bean->getTableName();
     //jc: added this for beans that do not actually have a table, namely
     //ForecastOpportunities
     if ($tablename == 'does_not_exist' || $tablename == '') {
         return '';
     }
     global $dictionary;
     $engine = null;
     if (isset($dictionary[$bean->getObjectName()]['engine']) && !empty($dictionary[$bean->getObjectName()]['engine'])) {
         $engine = $dictionary[$bean->getObjectName()]['engine'];
     }
     return $this->repairTableParams($tablename, $fielddefs, $indices, $execute, $engine);
 }