[pLog-svn] r2249 - in plog/trunk/class/database/pdb: . datadict drivers

oscar at devel.plogworld.net oscar at devel.plogworld.net
Sun Jun 19 21:44:44 GMT 2005


Author: oscar
Date: 2005-06-19 21:44:43 +0000 (Sun, 19 Jun 2005)
New Revision: 2249

Added:
   plog/trunk/class/database/pdb/datadict/
   plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php
   plog/trunk/class/database/pdb/datadict/pdbfielddescobject.class.php
   plog/trunk/class/database/pdb/datadict/pdbmysqldatadict.class.php
Modified:
   plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php
   plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php
   plog/trunk/class/database/pdb/drivers/pdbmysqlrecordset.class.php
   plog/trunk/class/database/pdb/drivers/pdbrecordset.class.php
   plog/trunk/class/database/pdb/pdb.class.php
Log:
Added support for 'data dictionaries' (http://phplens.com/lens/adodb/docs-datadict.htm) which
is a feature that I very much liked from ADOdb and that was used in many plugins... It has 
definitely added some extra code but 98% of it is loaded dynamically only when needed. The size
increase in driver is almost unnoticeable, though it has grown.
This commit also means that we do not depend on ADOdb anymore at all, and all the plugins that
relied on this feature (atom, karma, etc) are now working just fine under 1.1 without any changes.
I am sure we can still shrink the size of the code a bit more but the current size is still
within the limits of normality :)


Added: plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php
===================================================================
--- plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php	2005-06-19 09:17:01 UTC (rev 2248)
+++ plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php	2005-06-19 21:44:43 UTC (rev 2249)
@@ -0,0 +1,708 @@
+<?php
+
+    /** 
+      V4.54 5 Nov 2004  (c) 2000-2004 John Lim (jlim at natsoft.com.my). All rights reserved.
+      Released under both BSD license and Lesser GPL library license. 
+      Whenever there is any discrepancy between the two licenses, 
+      the BSD license will take precedence.
+    */
+    
+    include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
+
+    // compatibility stuff    
+    if (!function_exists('ctype_alnum')) {
+        function ctype_alnum($text) {
+            return preg_match('/^[a-z0-9]*$/i', $text);
+        }
+    }
+
+    
+    /**
+     * Base class for data dictionaries. Implements most of the functionality.
+     *
+     * \ingroup PDb
+     */    
+    class PDbBaseDataDict extends Object 
+    {
+        var $connection;
+        var $debug = false;
+        var $dropTable = 'DROP TABLE %s';
+        var $renameTable = 'RENAME TABLE %s TO %s'; 
+        var $dropIndex = 'DROP INDEX %s';
+        var $addCol = ' ADD';
+        var $alterCol = ' ALTER COLUMN';
+        var $dropCol = ' DROP COLUMN';
+        var $renameColumn = 'ALTER TABLE %s RENAME COLUMN %s TO %s';	// table, old-column, new-column, column-definitions (not used by default)
+        var $nameRegex = '\w';
+        var $schema = false;
+        var $serverInfo = array();
+        var $autoIncrement = false;
+        var $dataProvider;
+        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.
+                                
+    
+        /**
+            Parse arguments, treat "text" (text) and 'text' as quotation marks.
+            To escape, use "" or '' or ))
+            
+            Will read in "abc def" sans quotes, as: abc def
+            Same with 'abc def'.
+            However if `abc def`, then will read in as `abc def`
+            
+            @param endstmtchar    Character that indicates end of statement
+            @param tokenchars     Include the following characters in tokens apart from A-Z and 0-9 
+            @returns 2 dimensional array containing parsed tokens.
+        */
+        function Lens_ParseArgs($args,$endstmtchar=',',$tokenchars='_.-')
+        {
+            $pos = 0;
+            $intoken = false;
+            $stmtno = 0;
+            $endquote = false;
+            $tokens = array();
+            $tokens[$stmtno] = array();
+            $max = strlen($args);
+            $quoted = false;
+            
+            while ($pos < $max) {
+                $ch = substr($args,$pos,1);
+                switch($ch) {
+                case ' ':
+                case "\t":
+                case "\n":
+                case "\r":
+                    if (!$quoted) {
+                        if ($intoken) {
+                            $intoken = false;
+                            $tokens[$stmtno][] = implode('',$tokarr);
+                        }
+                        break;
+                    }
+                    
+                    $tokarr[] = $ch;
+                    break;
+                
+                case '`':
+                    if ($intoken) $tokarr[] = $ch;
+                case '(':
+                case ')':	
+                case '"':
+                case "'":
+                    
+                    if ($intoken) {
+                        if (empty($endquote)) {
+                            $tokens[$stmtno][] = implode('',$tokarr);
+                            if ($ch == '(') $endquote = ')';
+                            else $endquote = $ch;
+                            $quoted = true;
+                            $intoken = true;
+                            $tokarr = array();
+                        } else if ($endquote == $ch) {
+                            $ch2 = substr($args,$pos+1,1);
+                            if ($ch2 == $endquote) {
+                                $pos += 1;
+                                $tokarr[] = $ch2;
+                            } else {
+                                $quoted = false;
+                                $intoken = false;
+                                $tokens[$stmtno][] = implode('',$tokarr);
+                                $endquote = '';
+                            }
+                        } else
+                            $tokarr[] = $ch;
+                            
+                    }else {
+                    
+                        if ($ch == '(') $endquote = ')';
+                        else $endquote = $ch;
+                        $quoted = true;
+                        $intoken = true;
+                        $tokarr = array();
+                        if ($ch == '`') $tokarr[] = '`';
+                    }
+                    break;
+                    
+                default:
+                    
+                    if (!$intoken) {
+                        if ($ch == $endstmtchar) {
+                            $stmtno += 1;
+                            $tokens[$stmtno] = array();
+                            break;
+                        }
+                    
+                        $intoken = true;
+                        $quoted = false;
+                        $endquote = false;
+                        $tokarr = array();
+            
+                    }
+                    
+                    if ($quoted) $tokarr[] = $ch;
+                    else if (ctype_alnum($ch) || strpos($tokenchars,$ch) !== false) $tokarr[] = $ch;
+                    else {
+                        if ($ch == $endstmtchar) {			
+                            $tokens[$stmtno][] = implode('',$tokarr);
+                            $stmtno += 1;
+                            $tokens[$stmtno] = array();
+                            $intoken = false;
+                            $tokarr = array();
+                            break;
+                        }
+                        $tokens[$stmtno][] = implode('',$tokarr);
+                        $tokens[$stmtno][] = $ch;
+                        $intoken = false;
+                    }
+                }
+                $pos += 1;
+            }
+            if ($intoken) $tokens[$stmtno][] = implode('',$tokarr);
+            
+            return $tokens;
+        }
+        
+        function &MetaTables()
+        {
+            if (!$this->connection->IsConnected()) return array();
+            return $this->connection->MetaTables();
+        }
+        
+        function &MetaColumns($tab, $upper=true, $schema=false)
+        {
+            if (!$this->connection->IsConnected()) return array();
+            return $this->connection->MetaColumns($this->TableName($tab), $upper, $schema);
+        }
+        
+        function &MetaPrimaryKeys($tab,$owner=false,$intkey=false)
+        {
+            if (!$this->connection->IsConnected()) return array();
+            return $this->connection->MetaPrimaryKeys($this->TableName($tab), $owner, $intkey);
+        }
+        
+        function &MetaIndexes($table, $primary = false, $owner = false)
+        {
+            if (!$this->connection->IsConnected()) return array();
+            return $this->connection->MetaIndexes($this->TableName($table), $primary, $owner);
+        }
+        
+        function NameQuote($name = NULL)
+        {
+            if (!is_string($name)) {
+                return FALSE;
+            }
+            
+            $name = trim($name);
+            
+            if ( !is_object($this->connection) ) {
+                return $name;
+            }
+            
+            $quote = $this->connection->nameQuote;
+            
+            // if name is of the form `name`, quote it
+            if ( preg_match('/^`(.+)`$/', $name, $matches) ) {
+                return $quote . $matches[1] . $quote;
+            }
+            
+            // if name contains special characters, quote it
+            if ( !preg_match('/^[' . $this->nameRegex . ']+$/', $name) ) {
+                return $quote . $name . $quote;
+            }
+            
+            return $name;
+        }
+        
+        function TableName($name)
+        {
+            if ( $this->schema ) {
+                return $this->NameQuote($this->schema) .'.'. $this->NameQuote($name);
+            }
+            return $this->NameQuote($name);
+        }
+        
+        // Executes the sql array returned by GetTableSQL and GetIndexSQL
+        function ExecuteSQLArray($sql, $continueOnError = true)
+        {
+            $rez = 2;
+            $conn = &$this->connection;
+            $saved = $conn->debug;
+            foreach($sql as $line) {
+                
+                if ($this->debug) $conn->debug = true;
+                $ok = $conn->Execute($line);
+                $conn->debug = $saved;
+                if (!$ok) {
+                    if ($this->debug) print($conn->ErrorMsg());
+                    if (!$continueOnError) return 0;
+                    $rez = 1;
+                }
+            }
+            return $rez;
+        }
+        
+        /*
+             Returns the actual type given a character code.
+            
+            C:  varchar
+            X:  CLOB (character large object) or largest varchar size if CLOB is not supported
+            C2: Multibyte varchar
+            X2: Multibyte CLOB
+            
+            B:  BLOB (binary large object)
+            
+            D:  Date
+            T:  Date-time 
+            L:  Integer field suitable for storing booleans (0 or 1)
+            I:  Integer
+            F:  Floating point number
+            N:  Numeric or decimal number
+        */
+        
+        function ActualType($meta)
+        {
+            return $meta;
+        }
+        
+        function CreateDatabase($dbname,$options=false)
+        {
+            $options = $this->_Options($options);
+            $sql = array();
+            
+            $s = 'CREATE DATABASE ' . $this->NameQuote($dbname);
+            if (isset($options[$this->upperName]))
+                $s .= ' '.$options[$this->upperName];
+            
+            $sql[] = $s;
+            return $sql;
+        }
+        
+        /*
+         Generates the SQL to create index. Returns an array of sql strings.
+        */
+        function CreateIndexSQL($idxname, $tabname, $flds, $idxoptions = false)
+        {
+            if (!is_array($flds)) {
+                $flds = explode(',',$flds);
+            }
+            
+            foreach($flds as $key => $fld) {
+                $flds[$key] = $this->NameQuote($fld);
+            }
+            
+            return $this->_IndexSQL($this->NameQuote($idxname), $this->TableName($tabname), $flds, $this->_Options($idxoptions));
+        }
+        
+        function DropIndexSQL ($idxname, $tabname = NULL)
+        {
+            return array(sprintf($this->dropIndex, $this->NameQuote($idxname), $this->TableName($tabname)));
+        }
+        
+        function SetSchema($schema)
+        {
+            $this->schema = $schema;
+        }
+        
+        function AddColumnSQL($tabname, $flds)
+        {
+            $tabname = $this->TableName ($tabname);
+            $sql = array();
+            list($lines,$pkey) = $this->_GenFields($flds);
+            $alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' ';
+            foreach($lines as $v) {
+                $sql[] = $alter . $v;
+            }
+            return $sql;
+        }
+        
+        /**
+         * Change the definition of one column
+         *
+         * As some DBM's can't do that on there own, you need to supply the complete defintion of the new table,
+         * to allow, recreating the table and copying the content over to the new table
+         * @param string $tabname table-name
+         * @param string $flds column-name and type for the changed column
+         * @param string $tableflds='' complete defintion of the new table, eg. for postgres, default ''
+         * @param array/string $tableoptions='' options for the new table see CreateTableSQL, default ''
+         * @return array with SQL strings
+         */
+        function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+        {
+            $tabname = $this->TableName ($tabname);
+            $sql = array();
+            list($lines,$pkey) = $this->_GenFields($flds);
+            $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' ';
+            foreach($lines as $v) {
+                $sql[] = $alter . $v;
+            }
+            return $sql;
+        }
+        
+        /**
+         * Rename one column
+         *
+         * Some DBM's can only do this together with changeing the type of the column (even if that stays the same, eg. mysql)
+         * @param string $tabname table-name
+         * @param string $oldcolumn column-name to be renamed
+         * @param string $newcolumn new column-name
+         * @param string $flds='' complete column-defintion-string like for AddColumnSQL, only used by mysql atm., default=''
+         * @return array with SQL strings
+         */
+        function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='')
+        {
+            $tabname = $this->TableName ($tabname);
+            if ($flds) {
+                list($lines,$pkey) = $this->_GenFields($flds);
+                list(,$first) = each($lines);
+                list(,$column_def) = split("[\t ]+",$first,2);
+            }
+            return array(sprintf($this->renameColumn,$tabname,$this->NameQuote($oldcolumn),$this->NameQuote($newcolumn),$column_def));
+        }
+            
+        /**
+         * Drop one column
+         *
+         * Some DBM's can't do that on there own, you need to supply the complete defintion of the new table,
+         * to allow, recreating the table and copying the content over to the new table
+         * @param string $tabname table-name
+         * @param string $flds column-name and type for the changed column
+         * @param string $tableflds='' complete defintion of the new table, eg. for postgres, default ''
+         * @param array/string $tableoptions='' options for the new table see CreateTableSQL, default ''
+         * @return array with SQL strings
+         */
+        function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+        {
+            $tabname = $this->TableName ($tabname);
+            if (!is_array($flds)) $flds = explode(',',$flds);
+            $sql = array();
+            $alter = 'ALTER TABLE ' . $tabname . $this->dropCol . ' ';
+            foreach($flds as $v) {
+                $sql[] = $alter . $this->NameQuote($v);
+            }
+            return $sql;
+        }
+        
+        function DropTableSQL($tabname)
+        {
+            return array (sprintf($this->dropTable, $this->TableName($tabname)));
+        }
+        
+        function RenameTableSQL($tabname,$newname)
+        {
+            return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname)));
+        }	
+        
+        /*
+         Generate the SQL to create table. Returns an array of sql strings.
+        */
+        function CreateTableSQL($tabname, $flds, $tableoptions=false)
+        {
+            if (!$tableoptions) $tableoptions = array();
+            
+            list($lines,$pkey) = $this->_GenFields($flds, true);
+            
+            $taboptions = $this->_Options($tableoptions);
+            $tabname = $this->TableName ($tabname);
+            $sql = $this->_TableSQL($tabname,$lines,$pkey,$taboptions);
+            
+            //$tsql = $this->_Triggers($tabname,$taboptions);
+            foreach($tsql as $s) $sql[] = $s;
+            
+            return $sql;
+        }
+        
+        function _array_change_key_case($an_array)
+        {
+            if (is_array($an_array)) {
+                $new_array = array();
+                foreach($an_array as $key=>$value)
+                    $new_array[strtoupper($key)] = $value;
+        
+                   return $new_array;
+           }
+        
+            return $an_array;
+        }
+        
+        function _GenFields($flds,$widespacing=false)
+        {
+            if (is_string($flds)) {
+                $padding = '     ';
+                $txt = $flds.$padding;
+                $flds = array();
+                $flds0 = PDbBaseDataDict::Lens_ParseArgs($txt,',');
+                $hasparam = false;
+                foreach($flds0 as $f0) {
+                    $f1 = array();
+                    foreach($f0 as $token) {
+                        switch (strtoupper($token)) {
+                        case 'CONSTRAINT':
+                        case 'DEFAULT': 
+                            $hasparam = $token;
+                            break;
+                        default:
+                            if ($hasparam) $f1[$hasparam] = $token;
+                            else $f1[] = $token;
+                            $hasparam = false;
+                            break;
+                        }
+                    }
+                    $flds[] = $f1;
+                    
+                }
+            }
+            $this->autoIncrement = false;
+            $lines = array();
+            $pkey = array();
+            foreach($flds as $fld) {
+                $fld = PDbBaseDataDict::_array_change_key_case($fld);
+            
+                $fname = false;
+                $fdefault = false;
+                $fautoinc = false;
+                $ftype = false;
+                $fsize = false;
+                $fprec = false;
+                $fprimary = false;
+                $fnoquote = false;
+                $fdefts = false;
+                $fdefdate = false;
+                $fconstraint = false;
+                $fnotnull = false;
+                $funsigned = false;
+                
+                //-----------------
+                // Parse attributes
+                foreach($fld as $attr => $v) {
+                    if ($attr == 2 && is_numeric($v)) $attr = 'SIZE';
+                    else if (is_numeric($attr) && $attr > 1 && !is_numeric($v)) $attr = strtoupper($v);
+                    
+                    switch($attr) {
+                    case '0':
+                    case 'NAME': 	$fname = $v; break;
+                    case '1':
+                    case 'TYPE': 	$ty = $v; $ftype = $this->ActualType(strtoupper($v)); break;
+                    
+                    case 'SIZE': 	
+                                    $dotat = strpos($v,'.'); if ($dotat === false) $dotat = strpos($v,',');
+                                    if ($dotat === false) $fsize = $v;
+                                    else {
+                                        $fsize = substr($v,0,$dotat);
+                                        $fprec = substr($v,$dotat+1);
+                                    }
+                                    break;
+                    case 'UNSIGNED': $funsigned = true; break;
+                    case 'AUTOINCREMENT':
+                    case 'AUTO':	$fautoinc = true; $fnotnull = true; break;
+                    case 'KEY':
+                    case 'PRIMARY':	$fprimary = $v; $fnotnull = true; break;
+                    case 'DEF':
+                    case 'DEFAULT': $fdefault = $v; break;
+                    case 'NOTNULL': $fnotnull = $v; break;
+                    case 'NOQUOTE': $fnoquote = $v; break;
+                    case 'DEFDATE': $fdefdate = $v; break;
+                    case 'DEFTIMESTAMP': $fdefts = $v; break;
+                    case 'CONSTRAINT': $fconstraint = $v; break;
+                    } //switch
+                } // foreach $fld
+                
+                //--------------------
+                // VALIDATE FIELD INFO
+                if (!strlen($fname)) {
+                    if ($this->debug) print("Undefined NAME");
+                    return false;
+                }
+                
+                $fid = strtoupper(preg_replace('/^`(.+)`$/', '$1', $fname));
+                $fname = $this->NameQuote($fname);
+                
+                if (!strlen($ftype)) {
+                    if ($this->debug) print("Undefined TYPE for field '$fname'");
+                    return false;
+                } else {
+                    $ftype = strtoupper($ftype);
+                }
+                
+                $ftype = $this->_GetSize($ftype, $ty, $fsize, $fprec);
+                
+                if ($ty == 'X' || $ty == 'X2' || $ty == 'B') $fnotnull = false; // some blob types do not accept nulls
+                
+                if ($fprimary) $pkey[] = $fname;
+                
+                // some databases do not allow blobs to have defaults
+                if ($ty == 'X') $fdefault = false;
+                
+                //--------------------
+                // CONSTRUCT FIELD SQL
+                if ($fdefts) {
+                    if (substr($this->connection->_type,0,5) == 'mysql') {
+                        $ftype = 'TIMESTAMP';
+                    } else {
+                        $fdefault = $this->connection->sysTimeStamp;
+                    }
+                } else if ($fdefdate) {
+                    if (substr($this->connection->_type,0,5) == 'mysql') {
+                        $ftype = 'TIMESTAMP';
+                    } else {
+                        $fdefault = $this->connection->sysDate;
+                    }
+                } 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);
+                $suffix = $this->_CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned);
+                
+                if ($widespacing) $fname = str_pad($fname,24);
+                $lines[$fid] = $fname.' '.$ftype.$suffix;
+                
+                if ($fautoinc) $this->autoIncrement = true;
+            } // foreach $flds
+            
+            return array($lines,$pkey);
+        }
+        /*
+             GENERATE THE SIZE PART OF THE DATATYPE
+                $ftype is the actual type
+                $ty is the type defined originally in the DDL
+        */
+        function _GetSize($ftype, $ty, $fsize, $fprec)
+        {
+            if (strlen($fsize) && $ty != 'X' && $ty != 'B' && strpos($ftype,'(') === false) {
+                $ftype .= "(".$fsize;
+                if (strlen($fprec)) $ftype .= ",".$fprec;
+                $ftype .= ')';
+            }
+            return $ftype;
+        }
+        
+        
+        // return string must begin with space
+        function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint)
+        {	
+            $suffix = '';
+            if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+            if ($fnotnull) $suffix .= ' NOT NULL';
+            if ($fconstraint) $suffix .= ' '.$fconstraint;
+            return $suffix;
+        }
+        
+        function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
+        {
+            $sql = array();
+            
+            if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
+                $sql[] = sprintf ($this->dropIndex, $idxname);
+                if ( isset($idxoptions['DROP']) )
+                    return $sql;
+            }
+            
+            if ( empty ($flds) ) {
+                return $sql;
+            }
+            
+            $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
+        
+            $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' ';
+            
+            if ( isset($idxoptions[$this->upperName]) )
+                $s .= $idxoptions[$this->upperName];
+            
+            if ( is_array($flds) )
+                $flds = implode(', ',$flds);
+            $s .= '(' . $flds . ')';
+            $sql[] = $s;
+            
+            return $sql;
+        }
+        
+        function _DropAutoIncrement($tabname)
+        {
+            return false;
+        }
+        
+        function _TableSQL($tabname,$lines,$pkey,$tableoptions)
+        {
+            $sql = array();
+            
+            if (isset($tableoptions['REPLACE']) || isset ($tableoptions['DROP'])) {
+                $sql[] = sprintf($this->dropTable,$tabname);
+                if ($this->autoIncrement) {
+                    $sInc = $this->_DropAutoIncrement($tabname);
+                    if ($sInc) $sql[] = $sInc;
+                }
+                if ( isset ($tableoptions['DROP']) ) {
+                    return $sql;
+                }
+            }
+            $s = "CREATE TABLE $tabname (\n";
+            $s .= implode(",\n", $lines);
+            if (sizeof($pkey)>0) {
+                $s .= ",\n                 PRIMARY KEY (";
+                $s .= implode(", ",$pkey).")";
+            }
+            if (isset($tableoptions['CONSTRAINTS'])) 
+                $s .= "\n".$tableoptions['CONSTRAINTS'];
+            
+            if (isset($tableoptions[$this->upperName.'_CONSTRAINTS'])) 
+                $s .= "\n".$tableoptions[$this->upperName.'_CONSTRAINTS'];
+            
+            $s .= "\n)";
+            if (isset($tableoptions[$this->upperName])) $s .= $tableoptions[$this->upperName];
+            $sql[] = $s;
+            
+            return $sql;
+        }
+        
+        /*
+            Sanitize options, so that array elements with no keys are promoted to keys
+        */
+        function _Options($opts)
+        {
+            if (!is_array($opts)) return array();
+            $newopts = array();
+            foreach($opts as $k => $v) {
+                if (is_numeric($k)) $newopts[strtoupper($v)] = $v;
+                else $newopts[strtoupper($k)] = $v;
+            }
+            return $newopts;
+        }
+        
+        /*
+        "Florian Buzin [ easywe ]" <florian.buzin#easywe.de>
+        
+        This function changes/adds new fields to your table. You don't
+        have to know if the col is new or not. It will check on its own.
+        */
+        function ChangeTableSQL($tablename, $flds, $tableoptions = false)
+        {
+            // check table exists
+            $cols = &$this->MetaColumns($tablename);
+            if ( empty($cols)) { 
+                return $this->CreateTableSQL($tablename, $flds, $tableoptions);
+            }
+            
+            // already exists, alter table instead
+            list($lines,$pkey) = $this->_GenFields($flds);
+            $alter = 'ALTER TABLE ' . $this->TableName($tablename);
+            foreach ( $lines as $id => $v ) {
+                if ( isset($cols[$id]) && is_object($cols[$id]) ) {
+                
+                    $flds = PDbBaseDataDict::Lens_ParseArgs($v,',');
+                    
+                    //  We are trying to change the size of the field, if not allowed, simply ignore the request.
+                    if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4)) continue;	 
+                 
+                    $sql[] = $alter . $this->alterCol . ' ' . $v;
+                } else {
+                    $sql[] = $alter . $this->addCol . ' ' . $v;
+                }
+            }
+            
+            return $sql;
+        }
+    }
+?>
\ No newline at end of file

Added: plog/trunk/class/database/pdb/datadict/pdbfielddescobject.class.php
===================================================================
--- plog/trunk/class/database/pdb/datadict/pdbfielddescobject.class.php	2005-06-19 09:17:01 UTC (rev 2248)
+++ plog/trunk/class/database/pdb/datadict/pdbfielddescobject.class.php	2005-06-19 21:44:43 UTC (rev 2249)
@@ -0,0 +1,18 @@
+<?php
+    include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
+
+    /**
+     * Helper class for FetchFields -- holds info on a column
+     *     
+     * \ingroup PDb
+     */    
+    class PDbFieldDescObject extends Object
+    {
+        var $name = '';
+        var $max_length=0;
+        var $type="";
+        var $not_null = false;
+        var $has_default = false;
+        var $default_value;    
+    }
+?>
\ No newline at end of file

Added: plog/trunk/class/database/pdb/datadict/pdbmysqldatadict.class.php
===================================================================
--- plog/trunk/class/database/pdb/datadict/pdbmysqldatadict.class.php	2005-06-19 09:17:01 UTC (rev 2248)
+++ plog/trunk/class/database/pdb/datadict/pdbmysqldatadict.class.php	2005-06-19 21:44:43 UTC (rev 2249)
@@ -0,0 +1,156 @@
+<?php
+    
+    /**
+      V4.62 2 Apr 2005  (c) 2000-2005 John Lim (jlim at natsoft.com.my). All rights reserved.
+      Released under both BSD license and Lesser GPL library license. 
+      Whenever there is any discrepancy between the two licenses, 
+      the BSD license will take precedence.
+    */
+    
+    include_once( PLOG_CLASS_PATH."class/database/pdb/datadict/pdbbasedatadict.class.php" );
+    
+    class PDbMysqlDataDict extends PDbBaseDataDict {
+        var $databaseType = 'mysql';
+        var $alterCol = ' MODIFY COLUMN';
+        var $alterTableAddIndex = true;
+        var $dropTable = 'DROP TABLE IF EXISTS %s'; // requires mysql 3.22 or later
+        
+        var $dropIndex = 'DROP INDEX %s ON %s';
+        var $renameColumn = 'ALTER TABLE %s CHANGE COLUMN %s %s %s';	// needs column-definition!
+        
+        function MetaType($t,$len=-1,$fieldobj=false)
+        {
+            if (is_object($t)) {
+                $fieldobj = $t;
+                $t = $fieldobj->type;
+                $len = $fieldobj->max_length;
+            }
+            $is_serial = is_object($fieldobj) && $fieldobj->primary_key && $fieldobj->auto_increment;
+            
+            $len = -1; // mysql max_length is not accurate
+            switch (strtoupper($t)) {
+            case 'STRING': 
+            case 'CHAR':
+            case 'VARCHAR': 
+            case 'TINYBLOB': 
+            case 'TINYTEXT': 
+            case 'ENUM': 
+            case 'SET':
+                if ($len <= $this->blobSize) return 'C';
+                
+            case 'TEXT':
+            case 'LONGTEXT': 
+            case 'MEDIUMTEXT':
+                return 'X';
+                
+            // php_mysql extension always returns 'blob' even if 'text'
+            // so we have to check whether binary...
+            case 'IMAGE':
+            case 'LONGBLOB': 
+            case 'BLOB':
+            case 'MEDIUMBLOB':
+                return !empty($fieldobj->binary) ? 'B' : 'X';
+                
+            case 'YEAR':
+            case 'DATE': return 'D';
+            
+            case 'TIME':
+            case 'DATETIME':
+            case 'TIMESTAMP': return 'T';
+            
+            case 'FLOAT':
+            case 'DOUBLE':
+                return 'F';
+                
+            case 'INT': 
+            case 'INTEGER': return $is_serial ? 'R' : 'I';
+            case 'TINYINT': return $is_serial ? 'R' : 'I1';
+            case 'SMALLINT': return $is_serial ? 'R' : 'I2';
+            case 'MEDIUMINT': return $is_serial ? 'R' : 'I4';
+            case 'BIGINT':  return $is_serial ? 'R' : 'I8';
+            default: return 'N';
+            }
+        }
+    
+        function ActualType($meta)
+        {
+            switch(strtoupper($meta)) {
+            case 'C': return 'VARCHAR';
+            case 'XL':return 'LONGTEXT';
+            case 'X': return 'TEXT';
+            
+            case 'C2': return 'VARCHAR';
+            case 'X2': return 'LONGTEXT';
+            
+            case 'B': return 'LONGBLOB';
+                
+            case 'D': return 'DATE';
+            case 'T': return 'DATETIME';
+            case 'L': return 'TINYINT';
+            
+            case 'R':
+            case 'I4':
+            case 'I': return 'INTEGER';
+            case 'I1': return 'TINYINT';
+            case 'I2': return 'SMALLINT';
+            case 'I8': return 'BIGINT';
+            
+            case 'F': return 'DOUBLE';
+            case 'N': return 'NUMERIC';
+            default:
+                return $meta;
+            }
+        }
+        
+        // return string must begin with space
+        function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+        {	
+            $suffix = '';
+            if ($funsigned) $suffix .= ' UNSIGNED';
+            if ($fnotnull) $suffix .= ' NOT NULL';
+            if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+            if ($fautoinc) $suffix .= ' AUTO_INCREMENT';
+            if ($fconstraint) $suffix .= ' '.$fconstraint;
+            return $suffix;
+        }        
+        
+        function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
+        {
+            $sql = array();
+            
+            if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
+                if ($this->alterTableAddIndex) $sql[] = "ALTER TABLE $tabname DROP INDEX $idxname";
+                else $sql[] = sprintf($this->dropIndex, $idxname, $tabname);
+    
+                if ( isset($idxoptions['DROP']) )
+                    return $sql;
+            }
+            
+            if ( empty ($flds) ) {
+                return $sql;
+            }
+            
+            if (isset($idxoptions['FULLTEXT'])) {
+                $unique = ' FULLTEXT';
+            } elseif (isset($idxoptions['UNIQUE'])) {
+                $unique = ' UNIQUE';
+            } else {
+                $unique = '';
+            }
+            
+            if ( is_array($flds) ) $flds = implode(', ',$flds);
+            
+            if ($this->alterTableAddIndex) $s = "ALTER TABLE $tabname ADD $unique INDEX $idxname ";
+            else $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname;
+            
+            $s .= ' (' . $flds . ')';
+            
+            if ( isset($idxoptions[$this->upperName]) )
+                $s .= $idxoptions[$this->upperName];
+            
+            $sql[] = $s;
+            
+            return $sql;
+        }
+    }
+?>
\ No newline at end of file

Modified: plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php
===================================================================
--- plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php	2005-06-19 09:17:01 UTC (rev 2248)
+++ plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php	2005-06-19 21:44:43 UTC (rev 2249)
@@ -11,21 +11,36 @@
      * whether we're going to use paging or not.
      */
     define( "DEFAULT_PAGING_ENABLED", -1 );	
-
+
+    /**
+     * \ingroup PDb
+     *
+     * This class provides the base methods that all database drivers are expected to implement. Some methods
+     * provide some common functionality that should be called even when the method is overwritten, so please make sure
+     * to call the method of the parent class for those that need it.
+     */
 	class PDbDriverBase extends Object
 	{
 		
 		var $_dbname;
 		var $_host;
 		var $_user;
-		var $_password;
-	
+		var $_password;
+		var $_connected;
+		var $_type = 'generic';
+		var $nameQuote = '`';
+		var $_debug = false;
+		var $_connected = false;
+	
+	    /**
+	     * Generates a new instance of the driver. Please use PDb::getDriver() instead
+	     *
+	     * @see PDb::getDriver()
+	     */
 		function PDbDriverBase()
 		{
 			$this->Object();
-			
-			$this->_debug = false;
-		}
+        }
 		
 		/** 
 		 * Allows drivers to use custom options
@@ -37,50 +52,128 @@
 		{
 			// to be implemented by child classes	
 		}
-		
+		
+		/**
+		 * Executes a query and returns a PDbResultSet as a result, or false if the query wasn't
+		 * successfully executed.
+		 *
+		 * This method must be implemented by database drivers.
+		 *
+		 * @param query A string with the query to execute
+		 * @param page Page of records, when using pagination. Leave empty if pagination is not needed.
+		 * @param itemsPerPage Amount of record per page, when using pagination.
+		 * @return A PDbResultSet object if successful or false otherwise
+		 */
 		function Execute( $query, $page = DEFAULT_PAGING_ENABLED, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
 		{
 			// to be implemented by child classes
 		}
-		
+		
+		/**
+		 * Starts a new connection to a databse
+		 *
+		 * Database drivers should call this method after providing their own implementation.
+		 *
+		 * @param host The host to which we're initiating the connection
+		 * @param username The username used to connecto the database
+		 * @param password Password assigned to the user above
+		 * @param dbname The name of the database to which we're connecting
+		 * @return Returns true if successful or false otherwise
+		 */
 		function Connect( $host, $username, $password, $dbname )
 		{
 			$this->_host = $host;
 			$this->_username = $username;
 			$this->_password = $password;
-			$this->_dbname = $dbname;
+			$this->_dbname = $dbname;
+			$this->_connected = true;
 			
 			// extra functionality to be implemented by child classes...
 		}
-		
+
+		/**
+		 * Starts a new persistent connection to the database
+		 *
+		 * Database drivers should call this method after providing their own implementation.
+		 *		 
+		 * @param host The host to which we're initiating the connection
+		 * @param username The username used to connecto the database
+		 * @param password Password assigned to the user above
+		 * @param dbname The name of the database to which we're connecting
+		 * @return Returns true if successful or false otherwise
+		 */		
 		function PConnect( $host, $username, $password, $dbname )
 		{
 			$this->_host = $host;
 			$this->_username = $username;
 			$this->_password = $password;
-			$this->_dbname = $dbname;
+			$this->_dbname = $dbname;
+			$this->_connected = true;
 			
 			// extra functionality to be implemented by child classes...
 		}
-
+
+        /**
+         * Closes the current connection to the database
+         *
+		 * This method must be implemented by database drivers.
+         *
+         * @return nothing
+         */
 		function Close()
 		{
 		    // to be implemented by child classes
 		}		
-		
+		
+		/**
+		 * Returns the last error message that was generated by the driver
+		 *
+		 * This method must be implemented by database drivers.
+		 *		 
+		 * @return A string representing an error message, if any.		 
+		 */
 		function ErrorMsg()
 		{
 			// to be implemented by child classes
 		}
-		
+		
+		/**
+		 * The row id as generated by the last INSERT operation.
+		 *
+		 * This method must be implemented by database drivers.		 
+		 *
+		 * @return A row id
+		 */
 		function Insert_ID()
 		{
 			// to be implemented by child classes
 		}
-		
+		
+		/**
+		 * Returns the number of rows affected by the last UPDATE, INSERT or DELETE operation.
+		 * Use PDbRecordSet::Row_Count() to retrieve the number of rows in a SELECT operation.
+		 *
+		 * This method must be implemented by database drivers.		 
+		 * 
+		 * @return the number of affected rows
+		 * @see PDbRecordSet::Row_Count()
+		 */
 		function Affected_Rows()
 		{
 			// to be implemented by child classes
+		}
+		
+		/**
+		 * Returns true if the driver is currently connected to a database. Connections usually happen
+		 * after Connect or PConnect are called
+		 *
+		 * @return true if the driver is currently conneced or false otherwise
+		 * @see PDbDriverBase::PConnect()
+		 * @see PDbDriverBase::Connect()
+		 */
+		function IsConnected()
+		{
+		   return( $this->_connected );
 		}
 		
 		/**
@@ -94,22 +187,22 @@
 		    
 		    return( true );
 		}
-		
+		
+		/**
+		 * Activates the debug stuff.
+		 *
+		 * @param debug Whether debug should be enabled or not
+		 */
 		function setDebug( $debug )
 		{
 		    $this->_debug = $debug;
-		}		
+		}
 
-
-
         /**
          * Start of DB dependent code, be sure to override these methods in
          * your driver class, if the generic version are not good enough for
          * your driver.
          */ 
-
-
-
         function buildSelectQuery( $tableName,
                                    $fieldsToFetch,
                                    $whereColumn,
@@ -183,6 +276,201 @@
             $queryPart  = $columnName . ' ' . $operator . ' ';
             $queryPart .= Db::quoteValue( $columnValue );
             return $queryPart;
+        }
+        
+        /**
+         * for compatibility with ADOdb. Use Db::qstr() instead
+         *
+         * @private
+         */
+        function qstr( $string )         
+        {
+            return( Db::qstr( $string ));
+        }
+        
+        /**
+         * Load the correct data dictionary driver. Child classes should overwrite this method
+         * and provide the right driver name so that this method can be called without parameters.
+         *
+         * @param driverName the driver name.
+         * @param A reference to the driver-specific PDbBaseDataDict object
+         */
+        function &getDriverDataDictionary( $driverName ) 
+        {            
+            $dataDictPath = PLOG_CLASS_PATH."class/database/pdb/datadict/pdb{$driverName}datadict.class.php";
+            
+            // check if the driver exists at all
+            if( !is_readable( $dataDictPath )) {
+                throw( new Exception( "Cannot load data dictionary for driver $driverName!" ));
+                die();
+            }
+            
+            //print( "Loading datadict driver $dataDictPath...<br/>" );
+            
+            include_once( strtolower($dataDictPath));
+            
+            $className = "PDb{$driverName}DataDict";
+            $class =& new $className();
+            
+            $class->dataProvider = $this;
+            $class->connection = &$this;
+            
+            return( $class );
         }
+    
+        /**
+         * @param ttype can either be 'VIEW' or 'TABLE' or false.
+         *      If false, both views and tables are returned.
+         *      "VIEW" returns only views
+         *      "TABLE" returns only tables
+         * @param showSchema returns the schema/user with the table name, eg. USER.TABLE
+         * @param mask  is the input mask - only supported by oci8 and postgresql
+         *
+         * @return  array of tables for current database.
+         */
+        function &MetaTables($ttype=false,$showSchema=false,$mask=false)
+        {    
+            $metaTablesSQL = "SHOW TABLES";
+            
+            if ($showSchema && is_string($showSchema)) {
+                $metaTablesSQL .= " FROM $showSchema";
+            }
+            
+            if ($mask) {
+                $mask = $this->qstr($mask);
+                $metaTablesSQL .= " LIKE $mask";
+            }
+    
+            $rs = $this->Execute($metaTablesSQL);
+    
+            if ($rs === false) return false;
+            $arr =& $rs->GetArray();
+            $arr2 = array();
+    
+            if ($hast = ($ttype && isset($arr[0][1]))) {
+                $showt = strncmp($ttype,'T',1);
+            }
+    
+            for ($i=0; $i < sizeof($arr); $i++) {
+                if ($hast) {
+                    if ($showt == 0) {
+                        if (strncmp($arr[$i][1],'T',1) == 0) $arr2[] = trim($arr[$i][0]);
+                    } else {
+                        if (strncmp($arr[$i][1],'V',1) == 0) $arr2[] = trim($arr[$i][0]);
+                    }
+                } else
+                    $arr2[] = trim($arr[$i][0]);
+            }
+            $rs->Close();
+            return $arr2;
+        }
+    
+        /**
+         * @returns an array with the primary key columns in it.
+         *
+         * @param table
+         * @param owner
+         */
+        function MetaPrimaryKeys($table, $owner=false)
+        {
+        // owner not used in base class - see oci8
+            $p = array();
+            $objs =& $this->MetaColumns($table);
+            if ($objs) {
+                foreach($objs as $v) {
+                    if (!empty($v->primary_key))
+                        $p[] = $v->name;
+                }
+            }
+            if (sizeof($p)) return $p;
+            return false;
+        }
+    
+        /**
+         * List columns in a database as an array of ADOFieldObjects.
+         * See top of file for definition of object.
+         *
+         * @param table table name to query
+         * @param upper uppercase table name (required by some databases)
+         * @schema is optional database schema to use - not supported by all databases.
+         *
+         * @return  array of ADOFieldObjects for current table.
+         */
+        function &MetaColumns($table)
+        {
+            $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;
+                }
+            
+                $rs->Close();
+                return $retarr;
+        }
+    
+        /**
+         * List columns names in a table as an array.
+         * @param table table name to query
+         *
+         * @return  array of column names for current table.
+         */
+        function &MetaColumnNames($table, $numIndexes=false)
+        {
+            $objarr =& $this->MetaColumns($table);
+            if (!is_array($objarr)) return false;
+    
+            $arr = array();
+            if ($numIndexes) {
+                $i = 0;
+                foreach($objarr as $v) $arr[$i++] = $v->name;
+            } else
+                foreach($objarr as $v) $arr[strtoupper($v->name)] = $v->name;
+    
+            return $arr;
+        }        
 	}
-?>
+?>
\ No newline at end of file

Modified: plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php
===================================================================
--- plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php	2005-06-19 09:17:01 UTC (rev 2248)
+++ plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php	2005-06-19 21:44:43 UTC (rev 2249)
@@ -2,18 +2,32 @@
 
 	include_once( PLOG_CLASS_PATH."class/database/pdb/drivers/pdbdriverbase.class.php" );
 	include_once( PLOG_CLASS_PATH."class/database/pdb/drivers/pdbmysqlrecordset.class.php" );
-
+
+    /**
+     * \ingroup PDb
+     *
+     * MySQL driver for PDb
+     */
 	class PDbMySQLDriver extends PDbDriverBase
 	{
 		
 		var $_res;
 		var $_dbname;
-	
+	
+	    /**
+	     * Constructor of the driver. Doesn't do much.
+	     */
 		function PDbMySQLDriver()
 		{
-			$this->PDbDriverBase();			
+			$this->PDbDriverBase();
+			
+			// the driver name
+			$this->_type = 'mysql';	
 		}
-		
+		
+		/**
+		 * @see PDbDriverBase::Execute()
+		 */
 		function Execute( $query, $page = DEFAULT_PAGING_ENABLED, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
 		{
             if( $page > DEFAULT_PAGING_ENABLED ) {                	            
@@ -44,7 +58,10 @@
 			$rs = new PdbMySQLRecordSet( $result );
 			return( $rs );
 		}
-		
+		
+		/**
+		 * @see PDbDriverBase::Connect()
+		 */		
 		function Connect( $host, $username, $password, $dbname )
 		{
 			PDbDriverBase::Connect( $host, $username, $password, $dbname );
@@ -57,7 +74,10 @@
 			// continue otherwise and try to select our db
 			return( mysql_select_db( $dbname, $this->_res ));
 		}
-		
+		
+		/**
+		 * @see PDbDriverBase::PConnect()
+		 */		
 		function PConnect( $host, $username, $password, $dbname )
 		{
 			PDbDriverBase::Connect( $host, $username, $password, $dbname );			
@@ -70,25 +90,45 @@
 			// continue otherwise and try to select our db
 			return( mysql_select_db( $dbname, $this->_res ));
 		}
-		
+		
+		/**
+		 * @see PDbDriverBase::Close()
+		 */		
 		function Close()
 		{
 		    return( mysql_close( $this->_res ));
 		}
-		
+		
+		/**
+		 * @see PDbDriverBase::ErrorMsg()
+		 */		
 		function ErrorMsg()
 		{
 			return( mysql_error( $this->_res ));	
 		}
-		
+		
+		/**
+		 * @see PDbDriverBase::Insert_ID()
+		 */		
 		function Insert_ID()
 		{
 			return( mysql_insert_id( $this->_res ));
 		}
-		
+		
+		/**
+		 * @see PDbDriverBase::Affected_Rows()
+		 */		
 		function Affected_Rows()
 		{
 		    return( mysql_affected_rows( $this->_res ));
-		}
+		}
+		
+		/**
+		 * @see PDbDriverBase::getDriverDataDictionary()
+		 */		
+        function &getDriverDataDictionary()
+        {
+            return( PDbDriverBase::getDriverDataDictionary( 'mysql' ));
+        }
 	}
 ?>
\ No newline at end of file

Modified: plog/trunk/class/database/pdb/drivers/pdbmysqlrecordset.class.php
===================================================================
--- plog/trunk/class/database/pdb/drivers/pdbmysqlrecordset.class.php	2005-06-19 09:17:01 UTC (rev 2248)
+++ plog/trunk/class/database/pdb/drivers/pdbmysqlrecordset.class.php	2005-06-19 21:44:43 UTC (rev 2249)
@@ -1,25 +1,44 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/database/pdb/drivers/pdbrecordset.class.php" );
-
+
+    /**
+     * \ingroup PDb
+     *
+     * MySQL record sets.
+     *
+     * @see PDbRecordSet
+     */
 	class PdbMySQLRecordSet extends PdbRecordSet
 	{
-	
+	
+	    /**
+	     * @see PDbRecordSet
+	     */
 		function PdbMySQLRecordSet( $dbRes = null )
 		{
 			$this->PdbRecordSet( $dbRes );
 		}
-		
+
+	    /**
+	     * @see PDbRecordSet::FetchRow()
+	     */		
 		function FetchRow()
 		{
 			return( mysql_fetch_assoc( $this->_dbRes ));
 		}
-		
+
+	    /**
+	     * @see PDbRecordSet::RecordCount()
+	     */				
 		function RecordCount()
 		{
 			return( mysql_num_rows( $this->_dbRes ));
 		}
 		
+	    /**
+	     * @see PDbRecordSet::Close()
+	     */				
 		function Close()
 		{
 		    return( mysql_free_result( $this->_dbRes ));

Modified: plog/trunk/class/database/pdb/drivers/pdbrecordset.class.php
===================================================================
--- plog/trunk/class/database/pdb/drivers/pdbrecordset.class.php	2005-06-19 09:17:01 UTC (rev 2248)
+++ plog/trunk/class/database/pdb/drivers/pdbrecordset.class.php	2005-06-19 21:44:43 UTC (rev 2249)
@@ -1,7 +1,13 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
-
+
+    /**
+     * \ingroup PDb
+     *
+     * Abstract representation of a record set. Child classes are expected to extend this class
+     * to provide database-specific handling of record sets
+     */
 	class PdbRecordSet extends Object
 	{
 		
@@ -33,7 +39,8 @@
 		}
 		
 		/**
-		 * Alias for RecordCount()
+		 * Alias for RecordCount()		 
+		 *
 		 * @see RecordCount
 		 */
 		function RowCount()

Modified: plog/trunk/class/database/pdb/pdb.class.php
===================================================================
--- plog/trunk/class/database/pdb/pdb.class.php	2005-06-19 09:17:01 UTC (rev 2248)
+++ plog/trunk/class/database/pdb/pdb.class.php	2005-06-19 21:44:43 UTC (rev 2249)
@@ -1,5 +1,8 @@
-<?php
-
+<?php
+    /**
+	 * \defgroup PDb
+	 */
+	 
 	include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
 	
 	define( "PDB_DRIVER_FOLDER", PLOG_CLASS_PATH."class/database/pdb/drivers/" );
@@ -17,7 +20,9 @@
 	/**
 	 * PDb
 	 *
-	 * Plog's own lightweight database abstraction layer
+	 * Plog's own lightweight database abstraction layer
+	 *
+	 * \ingroup PDb
 	 */
 	class PDb extends Object
 	{
@@ -29,7 +34,15 @@
 		}
 		
 		/**
-		 * return the right driver type
+		 * return the right driver type
+		 *
+		 * @param driver the driver name. Supported types are
+		 *
+		 * - mysql
+		 *
+		 * @return An object of a class extending the PDbDriverBase class that implements the requested
+		 * database access.
+		 * @see PDbDriverBase
 		 */
 		function getDriver( $driver )
 		{
@@ -46,5 +59,24 @@
 			
 			return( $driverClass );
 		}
-	}
+	}
+	
+	/**
+	 * ADOdb compatibility
+	 *
+	 * @param driver A driver class whose data dictionary class we'd like to get. This method is obsolete
+	 * and you should call PDbDriverBase::getDriverDataDictionary(). This method is only here for compatibility
+	 * reasons.
+	 *
+	 * @see PDbDriverBase::getDriverDataDictionary()	 
+	 * @deprecated
+	 */
+    function NewDataDictionary( $driver )
+    {
+		$false = false;
+
+		//include_once(ADODB_DIR.'/adodb-datadict.inc.php');
+		//include_once( PLOG_CLASS_PATH."class/database/pdb/datadict/pdbdatadict.class.php" );
+		return( $driver->getDriverDataDictionary());
+    }
 ?>
\ No newline at end of file




More information about the pLog-svn mailing list