Friday, April 29, 2011

Custom datasource ignored

Hello,

CakePHP seems to be ignoring the $useDbConfig variable in my model.
I'm trying to use a custom datasource, but I'm getting the error:

Database table foo_files for model FooFiles was not found.

When I first loaded the model and new datasource, there were typos in
the datasource file which caused errors, so I know that the datasource
file is actually being loaded. Why is CakePHP still looking for a
database table?

My model, app/models/foo_files.php, contains:

class FooFiles extends AppModel {
var $name = 'FooFiles';
var $useTables = false;
var $useDbConfig = 'foofiles';
}

The app/config/database.php file has:

var $foofiles = array(
'datasource' => 'foofiles',
'workshopsdir' => '/some/dir',
);


My new datasource, app/models/datasources/myfiles_source.php, contains
(summarized):

class FoofilesSource extends DataSource {

protected $_schema = array(
'files' => array( ... )
);

public function listSources() {
return array('files');
}

public function describe($model) {
return $this->_schema['files'];
}

public function read($model, $queryData = array()) {
$workshopsDir = $config['workshopsdir'];
if(!isset($queryData['conditions'])) $queryData['conditions'] =
'all';

$events = array();
switch ($queryData['conditions']) {
default:
return(glob("$workshopsDir/*"));
break;

case $array[] = 'videos':
...
}
}


Any advice would be appreciated!

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: