[pLog-svn] r3131 - plog/trunk/class/database/pdb/datadict
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Sun Mar 26 17:37:24 GMT 2006
Author: oscar
Date: 2006-03-26 17:37:23 +0000 (Sun, 26 Mar 2006)
New Revision: 3131
Modified:
plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php
Log:
Added support for the definition of indexes when defining tables. Tested with mysql, it should work with other drivers if we ever get round to implementing support for those...
Modified: plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php
===================================================================
--- plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php 2006-03-26 15:25:59 UTC (rev 3130)
+++ plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php 2006-03-26 17:37:23 UTC (rev 3131)
@@ -38,6 +38,7 @@
var $serverInfo = array();
var $autoIncrement = false;
var $dataProvider;
+ var $upperName;
var $invalidResizeTypes4 = array('CLOB','BLOB','TEXT','DATE','TIME'); // for changetablesql
var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob
/// in other words, we use a text area for editting.
@@ -405,9 +406,11 @@
$taboptions = $this->_Options($tableoptions);
$tabname = $this->TableName ($tabname);
$sql = $this->_TableSQL($tabname,$lines,$pkey,$taboptions);
+ $idxs = $this->_IndexesSQL($tabname,$flds);
$tsql = $this->_Triggers($tabname,$taboptions);
foreach($tsql as $s) $sql[] = $s;
+ foreach($idxs as $i) $sql[] = $i;
return $sql;
}
@@ -439,6 +442,11 @@
$flds0 = PDbBaseDataDict::Lens_ParseArgs($txt,',');
$hasparam = false;
foreach($flds0 as $f0) {
+
+ // ignore index fields
+ if( in_array( $f0[0], Array( "INDEX", "FULLTEXT", "HASH", "UNIQUE", "CLUSTERED", "BITMAP", "DROP" )))
+ continue;
+
$f1 = array();
foreach($f0 as $token) {
switch (strtoupper($token)) {
@@ -461,6 +469,7 @@
$lines = array();
$pkey = array();
foreach($flds as $fld) {
+
$fld = PDbBaseDataDict::_array_change_key_case($fld);
$fname = false;
@@ -569,6 +578,43 @@
return array($lines,$pkey);
}
+
+ function _IndexesSQL($tabname,$flds)
+ {
+ if (is_string($flds)) {
+ $padding = ' ';
+ $txt = $flds.$padding;
+ $flds = array();
+ $flds0 = PDbBaseDataDict::Lens_ParseArgs($txt,',');
+ $hasparam = false;
+ foreach($flds0 as $f0) {
+
+ // ignore non-index fields
+ if( !in_array( $f0[0], Array( "INDEX", "FULLTEXT", "HASH", "UNIQUE", "CLUSTERED", "BITMAP", "DROP" )))
+ continue;
+
+ $flds[] = $f0;
+ }
+ }
+ $lines = array();
+ foreach($flds as $fld) {
+ $typeStr = $fld[0];
+ if( $typeStr == "INDEX" )
+ $type = false;
+ else
+ $type = Array( $typeStr );
+
+ $fld = PDbBaseDataDict::_array_change_key_case($fld);
+ $sql = $this->CreateIndexSQL( $fld[1], $tabname, $fld[2], $type );
+
+ foreach( $sql as $s )
+ $lines[] = $s;
+ }
+
+ return($lines);
+ }
+
+
/*
GENERATE THE SIZE PART OF THE DATATYPE
$ftype is the actual type
@@ -708,6 +754,6 @@
}
return $sql;
- }
+ }
}
?>
\ No newline at end of file
More information about the pLog-svn
mailing list