Wednesday, December 28, 2011

problems with custom datasource

Hi everyone,

I am writing a custom datasource with cake 2.x to get data from an api
call.
I did everything according to the twitter example in the book.
But when I run a Model->find('all') I get following error message:

Error: Database table examples for model Example was not found.

I suspect something wrong in the code of the DataSource.
This is my code for the DataSource (as you can see its pretty much
dummy code, just to get it working):

class ExampleSource extends DataSource {
protected $_schema = array(
'tweets' => array(
'id' => array(
'type' => 'integer',
'null' => true,
'key' => 'primary',
'length' => 11,
),
'text' => array(
'type' => 'string',
'null' => true,
'key' => 'primary',
'length' => 140
),
'status' => array(
'type' => 'string',
'null' => true,
'key' => 'primary',
'length' => 140
),
)
);

/**
* Constructor
*
*/
public function __construct($config) {
parent::__construct($config);
}

public function read($model, $queryData = array()) {
return array('nothing' => array('id' => 1, 'text' => 'nothing',
'status' => 'success'));
}

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

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


Any hints?

Thanks, flosky

--
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: