Archives

You are currently viewing archive for 27 July 2007
Category: Study
Posted by: hajime osako
Integer Data Types
TINYINT   1 byte
SMALLINT  2 bytes
MEDIUMINT 3 bytes
INT       4 bytes
BIGINT    8 bytes
INT(4)
The number 4 is the display width which is unrelated to the range of the data type.
Values shorter than the display width are padded with spaces as necessary.
It won't cause output truncation.
INT(4) column does not require half as much storage per value at INT(8). All INT data type require 4 bytes.
No display width is specified, MySQL use the width of the full range of values for the type. Ex: SMALLINT is 6 because the widest is -32768.


Floating-Point Data Types
FLOAT and DOUBLE may be used to represent approximate-value numbers in the native binary floating-point format used by the server host's CPU.
FLOAT  4 bytes
DOUBLE 8 bytes
You can specify explicit precision and scale, but if you don't, MySQL uses the maximum accuracy allowed by the hardware. Floating-point values are stored using mantissa/exponent representation.

Fixed-Point Data Types (DECIMAL)
The defaults for omitted precision and scale are 10 and 0.
The amount of storage required for DECIMAL is approximately four bytes are required per nine digits on each side of the decimal point.

The BIT Data Type
BIT(n) column presents the range of value 0 to 2n -1, and the storage requirement is approximately INT((n+7/8) bytes per value.
To wirete literal bit values, the leteral-value notation b'xxx' can be used. For example, b'1111' equals 15.
Category: Web dev
Posted by: hajime osako

function Validator()
{
// Constructor

// Declare Properties
this.regExpPatterns = new Object();
this.errMsgs = new Object();

// Declare Methods
this.validate = function(elm, ptn, msg)
{
var _str = null;

if(!ptn && elm.name && _parent.regExpPatterns[elm.name])
{
ptn = this.regExpPatterns[elm.name];
}

...
}

this.setAlertErr = function(bool)
{
this.alertErr = bool;
}

this.getAlertErr = function()
{
return this.alertErr;
}
}

OR

var Validator = new Function();

Validator.prototype.field1 = XXXXXX;
Validator.prototype.method1 = function (param1, param2)
{
[snip]
}
Category: Web dev
Posted by: hajime osako
Category: Web dev
Posted by: hajime osako
Blog.okuryu : PHP の array_multisort で多次元配列をソートする
$tmpOrderBy1 = array();
$tmpOrderBy2 = array();

foreach($dbResult as $key=>$row)
{
   $tmpOrderBy1[$key] = $row[orderby_column_1];
   $tmpOrderBy2[$key] = $row[orderby_column_2];
}

array_multisort($tmpOrderBy1, SORT_DESC, $tmpOrderBy2, SORT_ASC, $dbResult);