[floe] r406 committed - adding DefaultInstance config to StorageAdaptor

0 views
Skip to first unread message

fl...@googlecode.com

unread,
May 20, 2010, 4:34:19 PM5/20/10
to floe-c...@googlegroups.com
Revision: 406
Author: coretxt
Date: Thu May 20 13:33:53 2010
Log: adding DefaultInstance config to StorageAdaptor
http://code.google.com/p/floe/source/detail?r=406

Modified:
/trunk/src/repository/Query.class.php
/trunk/src/repository/store/StorageAdaptor.class.php

=======================================
--- /trunk/src/repository/Query.class.php Thu May 20 05:26:59 2010
+++ /trunk/src/repository/Query.class.php Thu May 20 13:33:53 2010
@@ -13,6 +13,8 @@
require_once dirname(__FILE__).'/../language/en/Inflect.class.php';
require_once 'store/mysql/MysqlQuery.class.php';

+if (!defined('StorageAdaptor_DefaultInstance'))
define('StorageAdaptor_DefaultInstance', 'Mysql');
+
/**
* Criteria based select query interface.
*
@@ -21,30 +23,23 @@
class Query {

protected $limitLower;
-
protected $limitUpper;
-
- protected $groupBy;
-
protected $orderBy;
-
protected $orderDir;
-
+ protected $groupBy;
protected $whereClauses;
-
protected $havingClauses;
-
protected $selectFields;
-
- protected $tableNames;
-
- public $tableName;
+ protected $tableName;

/**
* Factory method for returning a Query object supporting the default
storage adaptor.
*/
- static function instance() {
- return new MysqlQuery();
+ static function instance($adaptor=false) {
+ $adaptor = (($adaptor) ? $adaptor : StorageAdaptor_DefaultInstance);
+ $queryAdaptor = $adaptor."Query";
+ require_once 'store/'. strtolower($adaptor) .'/'.
$queryAdaptor .'.class.php';
+ return new $queryAdaptor();
}

function __construct() {
=======================================
--- /trunk/src/repository/store/StorageAdaptor.class.php Wed May 19
04:26:46 2010
+++ /trunk/src/repository/store/StorageAdaptor.class.php Thu May 20
13:33:53 2010
@@ -11,9 +11,7 @@
* @subpackage store
*/

-require_once 'mysql/MysqlConnection.class.php';
-require_once 'mysql/MysqlGateway.class.php';
-require_once 'mysql/MysqlQuery.class.php';
+if (!defined('StorageAdaptor_DefaultInstance'))
define('StorageAdaptor_DefaultInstance', 'Mysql');

/**
* High level wrapper around the gateway to a specific storage engine.
@@ -24,9 +22,7 @@
class StorageAdaptor {

private static $adaptor = null;
-
private static $implementation = null;
-
private $currentRecordType;

/**
@@ -38,10 +34,14 @@
}

/**
- * Returns a MysqlAdaptor instance
+ * Returns a default instance
*/
- static function gateway($plugin = false) {
- if (!self::$implementation) self::$implementation = new
MysqlGateway(new MysqlConnection());
+ static function gateway($adaptor = false) {
+ $queryAdaptor = (($adaptor) ? $adaptor :
StorageAdaptor_DefaultInstance)."Gateway";
+ $queryConnection = (($adaptor) ? $adaptor :
StorageAdaptor_DefaultInstance)."Connection";
+ require_once 'store/'. strtolower($adaptor) .'/'.
$queryAdaptor .'.class.php';
+ require_once 'store/'. strtolower($adaptor) .'/'.
$queryConnection .'.class.php';
+ if (!self::$implementation) self::$implementation = new
$queryAdaptor(new $queryConnection());
return self::$implementation;
}

--
You received this message because you are subscribed to the Google Groups "Floe Commits" group.
To post to this group, send email to floe-c...@googlegroups.com.
To unsubscribe from this group, send email to floe-commits...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/floe-commits?hl=en.

Reply all
Reply to author
Forward
0 new messages