[pLog-svn] r3152 - in plog/trunk/class/database/pdb: datadict
drivers
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Wed Mar 29 16:49:04 GMT 2006
Author: oscar
Date: 2006-03-29 16:49:04 +0000 (Wed, 29 Mar 2006)
New Revision: 3152
Modified:
plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php
plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php
Log:
a few changes related to data dictionaries.
Modified: plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php
===================================================================
--- plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php 2006-03-29 16:46:12 UTC (rev 3151)
+++ plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php 2006-03-29 16:49:04 UTC (rev 3152)
@@ -561,13 +561,16 @@
} else {
$fdefault = $this->connection->sysDate;
}
- } else if (strlen($fdefault) && !$fnoquote)
+ } else if (strlen($fdefault) && !$fnoquote) {
if ($ty == 'C' or $ty == 'X' or
( substr($fdefault,0,1) != "'" && !is_numeric($fdefault)))
if (strlen($fdefault) != 1 && substr($fdefault,0,1) == ' ' && substr($fdefault,strlen($fdefault)-1) == ' ')
$fdefault = trim($fdefault);
- else if (strtolower($fdefault) != 'null')
- $fdefault = $this->connection->qstr($fdefault);
+ else if (strtolower($fdefault) != 'null') {
+ //$fdefault = $this->connection->qstr($fdefault);
+ $fdefault = "'".$fdefault."'";
+ }
+ }
$suffix = $this->_CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned);
if ($widespacing) $fname = str_pad($fname,24);
Modified: plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php
===================================================================
--- plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php 2006-03-29 16:46:12 UTC (rev 3151)
+++ plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php 2006-03-29 16:49:04 UTC (rev 3152)
@@ -388,57 +388,59 @@
*/
function &MetaColumns($table)
{
+ include_once( PLOG_CLASS_PATH."class/database/pdb/datadict/pdbfielddescobject.class.php" );
+
$rs = $this->Execute(sprintf("SHOW COLUMNS FROM %s",$table));
- if (!is_object($rs))
- return false;
-
- include_once( PLOG_CLASS_PATH."class/database/pdb/datadict/pdbfielddescobject.class.php" );
-
- $retarr = array();
- while( $row = $rs->FetchRow()) {
- $fld = new PDbFieldDescObject();
-
- //
- // :TODO:
- // Is this mysql-specific stuff?? If so, it should be moved to the Mysql driver!!
- //
- $fld->name = $row["Field"];
- $type = $row["Type"];
-
- // split type into type(length):
- $fld->scale = null;
- if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
- $fld->type = $query_array[1];
- $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
- $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
- } elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
- $fld->type = $query_array[1];
- $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
- } else {
- $fld->type = $type;
- $fld->max_length = -1;
- }
- $fld->not_null = ($row["Null"] != 'YES');
- $fld->primary_key = ($row["Key"] == 'PRI');
- $fld->auto_increment = (strpos($row["Extra"], 'auto_increment') !== false);
- $fld->binary = (strpos($type,'blob') !== false);
- $fld->unsigned = (strpos($type,'unsigned') !== false);
-
- if (!$fld->binary) {
- $d = $row["Default"];
- if ($d != '' && $d != 'NULL') {
- $fld->has_default = true;
- $fld->default_value = $d;
- } else {
- $fld->has_default = false;
- }
- }
-
- $retarr[strtoupper($fld->name)] = $fld;
- }
+
+ $retarr = array();
+
+ if( !$rs )
+ return $retarr;
+
+ while( $row = $rs->FetchRow()) {
+ $fld = new PDbFieldDescObject();
+
+ //
+ // :TODO:
+ // Is this mysql-specific stuff?? If so, it should be moved to the Mysql driver!!
+ //
+ $fld->name = $row["Field"];
+ $type = $row["Type"];
+
+ // split type into type(length):
+ $fld->scale = null;
+ if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
+ $fld->type = $query_array[1];
+ $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+ $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
+ } elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
+ $fld->type = $query_array[1];
+ $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+ } else {
+ $fld->type = $type;
+ $fld->max_length = -1;
+ }
+ $fld->not_null = ($row["Null"] != 'YES');
+ $fld->primary_key = ($row["Key"] == 'PRI');
+ $fld->auto_increment = (strpos($row["Extra"], 'auto_increment') !== false);
+ $fld->binary = (strpos($type,'blob') !== false);
+ $fld->unsigned = (strpos($type,'unsigned') !== false);
+
+ if (!$fld->binary) {
+ $d = $row["Default"];
+ if ($d != '' && $d != 'NULL') {
+ $fld->has_default = true;
+ $fld->default_value = $d;
+ } else {
+ $fld->has_default = false;
+ }
+ }
+
+ $retarr[strtoupper($fld->name)] = $fld;
+ }
- $rs->Close();
- return $retarr;
+ $rs->Close();
+ return $retarr;
}
/**
More information about the pLog-svn
mailing list