Example #1
0
 public static function getEntityPrimaryFields($entityType)
 {
     static $schemas;
     if (is_null($schemas)) {
         $schemas = db_schema()->getSchema();
     }
     $table = self::$entityInfo[$entityType]['baseTable'];
     $table = db_getconnection()->replacePrefix('{' . $table . '}');
     return isset($schemas[$table]) ? $schemas[$table] : array();
 }
Example #2
0
function auto_field_config()
{
    $connect = db_getconnection();
    $schemas = db_schema()->getSchema();
    $fields = db_select('field_config', 'f')->fields('f')->execute()->fetchAll();
    foreach ($fields as $v) {
        $field = $connect->replacePrefix('{' . 'data_' . $v->field_name . '}');
        if (isset($schemas[$field])) {
            $config = array();
            foreach ($schemas[$field] as $k => $vv) {
                if (in_array($k, array('entity_type', 'entity_id', 'delta'))) {
                    continue;
                }
                $config[str_replace($v->field_name . '_', '', $k)] = $vv;
            }
            $data = array('columns' => $config);
            db_update('field_config')->fields(array('data' => serialize($data)))->condition('id', $v->id)->execute();
        }
    }
    echo 'done!';
}
 public static function getSchema($table)
 {
     static $schemas;
     if (is_null($schemas)) {
         $schemas = db_schema()->getSchema();
     }
     $table = db_getconnection()->replacePrefix('{' . $table . '}');
     return isset($schemas[$table]) ? $schemas[$table] : array();
 }