< DECIMAL: Setting Column Type   (Previous) Table of Contents (Next)   DROP >

DECIMAL: Getting Column Type

/**
 * Returns the regular expression needed for DECIMAL data types
 *
 * @return  string   the regular expression needed
 */
function getDecimalType() {
    return $this->DecimalType;
}

/**
 * Returns the SQL fragment needed for creating DECIMAL data types
 * in CREATE TABLE statements
 *
 * @return  string   the query fragment your DBMS needs
 */
function formatDecimalType($precision, $scale) {
    return preg_replace('/(\(\d+, *\d+\))/',
                        $this->DecimalType,
                        "($precision, $scale)");
}

require 'connect.inc';

$query = 'CREATE TABLE xyz (d ' . $p->formatDecimalType(2, 1) . ')';
echo $query;
$db->query($query);
$db->query('DROP TABLE xyz ' . $p->getDropRestrict());
access
CREATE TABLE xyz (d NUMERIC )
mysql
CREATE TABLE xyz (d DECIMAL(2, 1) )