diff --git a/app/controllers/tests_controller.php b/app/controllers/tests_controller.php index f85ea43a6..5211d2af9 100644 --- a/app/controllers/tests_controller.php +++ b/app/controllers/tests_controller.php @@ -44,7 +44,7 @@ class TestsController extends TestsHelper { function index () { $this->layout = null; - require_once TESTS.'menu.php'; + require_once TESTS.'index.php'; } /** * Runs all library and application tests diff --git a/config/routes.php b/config/routes.php index 391cc8d9b..1d81a3743 100644 --- a/config/routes.php +++ b/config/routes.php @@ -49,6 +49,6 @@ $Route->connect ('/pages/*', array('controller'=>'Pages', 'action'=>'display')); * Then we connect url '/test' to our test controller. This is helpfull in * developement. */ -$Route->connect ('/test', array('controller'=>'Tests', 'action'=>'test_all')); +$Route->connect ('/test', array('controller'=>'Tests', 'action'=>'index')); ?> diff --git a/libs/controller.php b/libs/controller.php index 362a02916..a16edf07f 100644 --- a/libs/controller.php +++ b/libs/controller.php @@ -226,11 +226,11 @@ class Controller extends Object $id = $this->params['pass']; } - + $dboFactory = DboFactory::getInstance($this->useDbConfig); + $this->db =& $dboFactory; + $model_class = Inflector::singularize($this->name); - $this->db = DboFactory::getInstance($this->useDbConfig); - if (class_exists($model_class) && ($this->uses === false)) { $this->models[$model_class] = new $model_class($id); @@ -495,7 +495,7 @@ class Controller extends Object $table = Inflector::singularize($this->name); // get all of the column names. - $classRegistry = ClassRegistry::getInstance(); + $classRegistry =& ClassRegistry::getInstance(); $objRegistryModel = $classRegistry->getObject($table); foreach ($objRegistryModel->_table_info as $tables) @@ -573,7 +573,7 @@ class Controller extends Object $fieldNames[ $tabl['name']]['options'] = array(); // get the list of options from the other model. - $registry = ClassRegistry::getInstance(); + $registry =& ClassRegistry::getInstance(); $otherModel = $registry->getObject($fieldNames[ $tabl['name']]['model']); if( is_object($otherModel) ) @@ -620,7 +620,7 @@ class Controller extends Object $fieldNames[ $tabl['name']]['options'] = array(); // get the list of options from the other model. - $registry = ClassRegistry::getInstance(); + $registry =& ClassRegistry::getInstance(); $otherModel = $registry->getObject($fieldNames[ $tabl['name']]['model']); if( is_object($otherModel) ) diff --git a/libs/model.php b/libs/model.php index b34bcdae2..f0fc0a76c 100644 --- a/libs/model.php +++ b/libs/model.php @@ -208,8 +208,19 @@ class Model extends Object */ function __construct ($id=false, $table=null, $db=null) { - $this->db = $db? $db: DboFactory::getInstance(); - $this->classRegistry = ClassRegistry::getInstance(); + + if($db != null) + { + $this->db =& $db; + } + else + { + $dboFactory = DboFactory::getInstance(); + $this->db =& $dboFactory ; + } + + + $this->classRegistry =& ClassRegistry::getInstance(); $this->classRegistry->addObject(get_class($this), $this); if ($id) diff --git a/libs/object.php b/libs/object.php index d33f8d0eb..607d51edc 100644 --- a/libs/object.php +++ b/libs/object.php @@ -47,12 +47,6 @@ uses('log'); */ class Object { -/** - * Database connection, if available. - * - * @var DBO - */ - var $db = null; /** * Log object @@ -71,7 +65,6 @@ class Object */ function Object() { - $this->db = DboFactory::getInstance(); $args = func_get_args(); register_shutdown_function(array(&$this, '__destruct')); call_user_func_array(array(&$this, '__construct'), $args); diff --git a/libs/scaffold.php b/libs/scaffold.php index 324f4f366..6734aa256 100644 --- a/libs/scaffold.php +++ b/libs/scaffold.php @@ -164,9 +164,7 @@ class Scaffold extends Object { { $model = $this->model; $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames(null,false) ); - $registry = ClassRegistry::getInstance(); - $objModel = $registry->getObject( $model ); - $this->controllerClass->set('data', $objModel->findAll()); + $this->controllerClass->set('data', $this->controllerClass->models[$this->model]->findAll()); $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'list.thtml'); } @@ -263,7 +261,8 @@ class Scaffold extends Object { function cleanUpDateFields() { // clean up the date fields - foreach( $this->controllerClass->models[$this->model]->_table_info as $table ) + $objModel = $this->controllerClass->models[$this->model]; + foreach( $objModel->_table_info as $table ) { foreach ($table as $field) {