Back to SqlsrvChangeItem class

Method fixInteger

private string
fixInteger
(mixed $type1, mixed $type2)
Fix up integer. Fixes problem with MySQL integer descriptions.
Parameters
  • string $type1 the column type
  • string $type2 the column attributes
Returns
  • string The original or changed column type.
Since
  • 2.5

Method fixInteger - Source code

/**
 * Fix up integer. Fixes problem with MySQL integer descriptions.
 * If you change a column to "integer unsigned" it shows
 * as "int(10) unsigned" in the check query.
 *
 * @param   string  $type1  the column type
 * @param   string  $type2  the column attributes
 *
 * @return  string  The original or changed column type.
 *
 * @since   2.5
 */
private function fixInteger($type1, $type2)
{
    $result = $type1;
    if (strtolower($type1) === 'integer' && strtolower(substr($type2, 0, 8)) === 'unsigned') {
        $result = 'int';
    }
    return $result;
}