Home » Database » MDB2 » Bug #7170
length/scale support for numeric types
Details
| Request #7170 | length/scale support for numeric types |
|---|---|
| Submitted | 2006-03-21 10:27 UTC |
| From | nolife at gmail dot com |
| Assigned | lsmith |
| Status | Closed |
| Package | MDB2 |
| PHP Version | 5.1.2 |
| OS | irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2006-03-21 10:27 UTC] nolife at gmail dot com
Description:
------------
There are a few issues with numeric datatypes and the oci8 driver (did not check other drivers).
for once: when the integer datatype is used oracle (9r2) changes it into a number(38) which is probably more than expected and required.
when the boolean datatype is used the oci8.php driver also uses an INT type internal, which means we have 38 digits for a true/false datatype.
a length parameter is not supported.
The patch below can be used to implements a length parameter for INT,NUMBER and DECIMAL. it also changes the default of INT for boolean to a NUMBER(1)
Test script:
---------------
Changes in:
/usr/share/php/MDB2/Driver/Datatype/oci8.php
-------------------------------------------------------
--- oci8_orig.php 2006-03-17 11:24:18.000000000 +0100
+++ oci8.php 2006-03-17 11:43:38.000000000 +0100
@@ -123,9 +123,11 @@
case 'blob':
return 'BLOB';
case 'integer':
- return 'INT';
+ $length = array_key_exists('length', $field)
+ ? $field['length'] : "*";
+ return 'NUMBER('.$length.')';
case 'boolean':
- return 'INT';
+ return 'NUMBER(1)';
case 'date':
case 'time':
case 'timestamp':
@@ -133,7 +135,9 @@
case 'float':
return 'NUMBER';
case 'decimal':
- return 'NUMBER(*,'.$db->options['decimal_places'].')';
+ $length = array_key_exists('length', $field)
+ ? $field['length'] : "*";
+ return 'NUMBER('.$length.','.$db->options['decimal_places'].')';
}
}
@@ -282,4 +286,4 @@
}
}
-?>
\ Kein Zeilenumbruch am Dateiende.
+?>
-------------------------------------------------------