prettify code

This commit is contained in:
Brion Vibber 2010-08-16 15:28:00 -07:00
parent eaa4ded053
commit 1a7d830fff

View File

@ -117,40 +117,37 @@ abstract class Managed_DataObject extends Memcached_DataObject
*/ */
function columnBitmap($column) function columnBitmap($column)
{ {
$type = 0; $type = $column['type'];
switch ($column['type']) { // For quoting style...
case 'int': $intTypes = array('int',
case 'serial': 'integer',
case 'numeric': 'float',
// Doesn't need quoting. 'serial',
$type |= DB_DATAOBJECT_INT; 'numeric');
break; if (in_array($type, $intTypes)) {
default: $style = DB_DATAOBJECT_INT;
// Value needs quoting in SQL literal statements. } else {
$type |= DB_DATAOBJECT_STR; $style = DB_DATAOBJECT_STR;
} }
switch ($column['type']) { // Data type formatting style...
case 'blob': $formatStyles = array('blob' => DB_DATAOBJECT_BLOB,
$type |= DB_DATAOBJECT_BLOB; 'text' => DB_DATAOBJECT_TXT,
break; 'date' => DB_DATAOBJECT_DATE,
case 'text': 'time' => DB_DATAOBJECT_TIME,
$type |= DB_DATAOBJECT_TXT; 'datetime' => DB_DATAOBJECT_DATE | DB_DATAOBJECT_TIME,
break; 'timestamp' => DB_DATAOBJECT_MYSQLTIMESTAMP);
case 'datetime':
$type |= DB_DATAOBJECT_DATE; if (isset($formatStyles[$type])) {
$type |= DB_DATAOBJECT_TIME; $style |= $formatStyles[$type];
break;
case 'timestamp':
$type |= DB_DATAOBJECT_MYSQLTIMESTAMP;
break;
} }
// Nullable?
if (!empty($column['not null'])) { if (!empty($column['not null'])) {
$type |= DB_DATAOBJECT_NOTNULL; $style |= DB_DATAOBJECT_NOTNULL;
} }
return $type; return $style;
} }
} }