2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
2007-11-23 02:10:19 +01:00
|
|
|
/**
|
|
|
|
* @param $defaultVal int
|
|
|
|
*/
|
2007-09-16 16:43:27 +02:00
|
|
|
class Int extends DBField {
|
|
|
|
|
2007-09-16 16:43:54 +02:00
|
|
|
function __construct($name, $defaultVal = 0) {
|
2007-09-16 16:43:27 +02:00
|
|
|
$this->defaultVal = is_int($defaultVal)
|
|
|
|
? $defaultVal
|
|
|
|
: 0;
|
|
|
|
|
|
|
|
parent::__construct($name);
|
|
|
|
}
|
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
function Formatted() {
|
|
|
|
return number_format($this->value);
|
|
|
|
}
|
2007-09-16 16:43:27 +02:00
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
function nullValue() {
|
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
|
|
|
|
function requireField() {
|
2007-09-16 16:43:27 +02:00
|
|
|
DB::requireField($this->tableName, $this->name, "int(11) not null default '{$this->defaultVal}'");
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
2007-09-16 16:43:27 +02:00
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
function Times() {
|
|
|
|
$output = new DataObjectSet();
|
|
|
|
for( $i = 0; $i < $this->value; $i++ )
|
|
|
|
$output->push( new ArrayData( array( 'Number' => $i + 1 ) ) );
|
2007-09-16 16:43:27 +02:00
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
return $output;
|
|
|
|
}
|
2007-09-16 16:43:27 +02:00
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
function Nice() {
|
|
|
|
return sprintf( '%d', $this->value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-23 02:10:19 +01:00
|
|
|
?>
|