[pLog-svn] r4681 - in plog/branches/lifetype-1.2: class/database class/database/pdb/drivers release
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Sat Feb 3 06:55:37 EST 2007
Author: oscar
Date: 2007-02-03 06:55:37 -0500 (Sat, 03 Feb 2007)
New Revision: 4681
Modified:
plog/branches/lifetype-1.2/class/database/db.class.php
plog/branches/lifetype-1.2/class/database/pdb/drivers/pdbdriverbase.class.php
plog/branches/lifetype-1.2/class/database/pdb/drivers/pdbmysqldriver.class.php
plog/branches/lifetype-1.2/release/config.properties.php.dist
Log:
Added a config file parameter to enable/disable support for FULLTEXT indexes when runnings searches. Since Mark had a good point about Chinese encoded in UTF-8, we cannot use character encoding to determine whether FULLTEXT can be used or not so we'll just leave it up to this configuration parameter. This feature is now disabled by default but we should provide instructions on how to enable it.
Modified: plog/branches/lifetype-1.2/class/database/db.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/database/db.class.php 2007-02-03 11:50:45 UTC (rev 4680)
+++ plog/branches/lifetype-1.2/class/database/db.class.php 2007-02-03 11:55:37 UTC (rev 4681)
@@ -85,10 +85,9 @@
die();
}
}
- // just in case, forcing to use indexing by field name instead of
- // by field number
- //$db->SetFetchMode( ADODB_FETCH_ASSOC );
- // comment out the line above if you're planning to test pdb
+
+ // pass the options to the driver, if any
+ $db->setDriverOpts( $fileConfig->getValue( "db_options" ));
}
return $db;
@@ -118,10 +117,6 @@
throw( new Exception( "getNewDb: Fatal error: could not connect to the database!" ));
die();
}
-
- // just in case, forcing to use indexing by field name instead of
- // by field number
- //$db->SetFetchMode( ADODB_FETCH_ASSOC );
}
return( $dbs[$key] );
Modified: plog/branches/lifetype-1.2/class/database/pdb/drivers/pdbdriverbase.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/database/pdb/drivers/pdbdriverbase.class.php 2007-02-03 11:50:45 UTC (rev 4680)
+++ plog/branches/lifetype-1.2/class/database/pdb/drivers/pdbdriverbase.class.php 2007-02-03 11:55:37 UTC (rev 4681)
@@ -23,6 +23,7 @@
var $nameQuote = '`';
var $_debug = false;
var $_connected = false;
+ var $_opts;
/**
* Generates a new instance of the driver. Please use PDb::getDriver() instead
@@ -31,7 +32,7 @@
*/
function PDbDriverBase()
{
-
+ $this->_opts = Array();
}
/**
@@ -42,10 +43,21 @@
*/
function setDriverOpt( $key, $value )
{
- // to be implemented by child classes
+ $this->_opts[$key] = $value;
}
/**
+ * Set the driver options via an array. This method will completely replace any
+ * options that have been set up until this moment via PDbDriverBase::setDriverOpt.
+ *
+ * @param opts An associative array containing driver-specific options
+ */
+ function setDriverOpts( $opts )
+ {
+ $this->_opts = $opts;
+ }
+
+ /**
* Executes a query and returns a PDbResultSet as a result, or false if the query wasn't
* successfully executed.
*
Modified: plog/branches/lifetype-1.2/class/database/pdb/drivers/pdbmysqldriver.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/database/pdb/drivers/pdbmysqldriver.class.php 2007-02-03 11:50:45 UTC (rev 4680)
+++ plog/branches/lifetype-1.2/class/database/pdb/drivers/pdbmysqldriver.class.php 2007-02-03 11:55:37 UTC (rev 4681)
@@ -158,17 +158,20 @@
}
/**
- * Returns true if the current database supports FULLTEXT searches. This method needs to be
- * implemented by child classes.
+ * Returns true if the current database supports FULLTEXT searches. This is currently
+ * configured in the database configuration file, config/config.properties.php:
*
- * @return true if FULLTEXT is supported, which is the case for most character encodings
+ * <pre>
+ * $config['db_options'] = Array( "enable_mysql_fulltext_search" => false );
+ * </pre>
+ *
+ * @return true if FULLTEXT is supported
*/
function isFullTextSupported()
{
- // array with all those MySQL character sets that don't support FULLTEXT searches
- $unsupportedCharacterSets = Array();
+ isset( $this->_opts["enable_mysql_fulltext_search"] ) ? $enableFullText = $this->_opts["enable_mysql_fulltext_search"] : $enableFullText = false;
- return( !in_array( $this->getDbCharacterSet(), $unsupportedCharacterSets ));
+ return( $enableFullText );
}
/**
Modified: plog/branches/lifetype-1.2/release/config.properties.php.dist
===================================================================
--- plog/branches/lifetype-1.2/release/config.properties.php.dist 2007-02-03 11:50:45 UTC (rev 4680)
+++ plog/branches/lifetype-1.2/release/config.properties.php.dist 2007-02-03 11:55:37 UTC (rev 4681)
@@ -41,4 +41,13 @@
# with the installation wizard, please make sure that you also rename the tables.
#
$config["db_prefix"] = "";
-?>
+
+#
+# This array is used to pass driver-specific parameters. Currently the only supported
+# one is enable_fulltext_search, that informs the MySQL driver that FULLTEXT indexes
+# can be used to speed up searches. It's disabled by default as it does not work with
+# languages such as Chinese or Japanese. In all other cases, you probably want to enable
+# this for performance reasons (searches are lot faster if using the FULLTEXT indexes)
+#
+$config["db_options"] = Array( "enable_mysql_fulltext_search" => false );
+?>
\ No newline at end of file
More information about the pLog-svn
mailing list