Exemple #1
0
 /**
  * Given a table column object, return true if the object's type matches the
  * specified $type parameter.  Return false if there is a mismatch that will
  * require table structure updates.
  *
  * @param \Zend\Db\Metadata\Object\ColumnObject $column       Object to check
  * @param string                                $expectedType Type to compare
  *
  * @return bool
  */
 protected function typeMatches($column, $expectedType)
 {
     // Get base type:
     $type = $column->getDataType();
     // If it's not a blob or a text (which don't have explicit sizes in our SQL),
     // we should see what the character length is, if any:
     if ($type != 'blob' && $type != 'text') {
         $charLen = $column->getCharacterMaximumLength();
         if ($charLen) {
             $type .= '(' . $charLen . ')';
         }
     }
     // If it's an integer, the expected type will have a parenthetical value;
     // this is a display width which we can't retrieve using the column metadata
     // object.  Since display width is not important to VuFind, we should ignore
     // this factor when comparing things.
     if ($type == 'int' || $type == 'tinyint' || $type == 'smallint' || $type == 'mediumint' || $type == 'bigint') {
         list($expectedType) = explode('(', $expectedType);
     }
     return $type == $expectedType;
 }