Advertisement
Guest User

Doctrine 2 patch to remove column prefixes

a guest
Mar 31st, 2012
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.31 KB | None | 0 0
  1. diff --git a/vendor/doctrine/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php b/vendor/doctrine/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php
  2. index c2d9240..efdb760 100644
  3. --- a/vendor/doctrine/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php
  4. +++ b/vendor/doctrine/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php
  5. @@ -345,6 +345,7 @@ class DatabaseDriver implements Driver
  6.       */
  7.      public function setFieldNameForColumn($tableName, $columnName, $fieldName)
  8.      {
  9. +        $fieldName = $this->deprefixFieldName($fieldName);
  10.          $this->fieldNamesForColumns[$tableName][$columnName] = $fieldName;
  11.      }
  12.  
  13. @@ -383,10 +384,23 @@ class DatabaseDriver implements Driver
  14.          if ($fk) {
  15.              $columnName = str_replace('_id', '', $columnName);
  16.          }
  17. +
  18. +        $columnName = $this->deprefixFieldName($columnName);
  19. +
  20.          return Inflector::camelize($columnName);
  21.      }
  22.  
  23.      /**
  24. +     * Remove column name prefix from field name, i.e. user_is_active -> is_active
  25. +     *
  26. +     * @param string $fieldName
  27. +     * @return string
  28. +     */
  29. +    private function deprefixFieldName( $fieldName ) {
  30. +        return implode('_',array_slice(explode('_',$fieldName),1));
  31. +    }
  32. +
  33. +    /**
  34.       * Set the namespace for the generated entities.
  35.       *
  36.       * @param string $namespace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement