flowctrl,

I don't know about datasources specifically but I know generally about
your problem. Possibly this example will put you on the path.

I wanted to modify a behavior I had connected to some models, call it
niceBehavior. So my models had this:
var $actsAs = array('niceBehavior');

and my new class is called fixNiceBehavior. It is like your example:
Class fixNiceBehavior Extends NiceBehavior {
//methods here
}

If run things now, any functions in my new class will throw the errors
you describe. But if I change my models to read:
var $actsAs = array('fixNiceBehavior');

I'll have BOTH classes and their properties and methods available
through fixNiceBehavior. So, if niceBehavior->do_magic() was a method;
because fixNiceBehavior extends niceBehavior, fixNiceBehavior-
>do_magic() is 'magically' available along with all my other newly
written properties and methods.

Other times, you'll have to break out the big guns to load your class.
App::import() will do that for you.
http://book.cakephp.org/view/1031/Saving-Your-Data#!/view/933/The-App-Class

Regards,
Don

On May 4, 4:21 pm, flowctrl <[email protected]> wrote:
> Hello,
>
> In CakePHP 1.3, how do I use a function in a custom datasource, from a
> model that uses that datasource?
>
> My custom datasource works for regular queries, but I want to extend
> the default "find" method to include a new parameter. In app/models/
> datasources/foofiles_source.php I have a function to find video files
> on the filesystem. For testing, it is:
>
> class FoofilesSource extends DataSource {
>
>    public function find_videos($videoQuery) {
>          return(array("This is in the foo_files datasource!",
> "w00t!"));
>    }
> …
>
> In the FooFiles model, I have:
>
>    function find($type, $options = array()) {
>       switch($type) {
>          case "videos":
>             $this->find_videos($options);
>             break;
>
>          default:
>             return parent::find($type, $options);
>             break;
>       }
>    }
>
> However, $this->find_videos($options) produces a fatal error:
> Fatal error: Call to undefined method FoofilesSource::query() in cake/
> libs/model/model.php on line 502
>
> If I use FoofilesSource::find_videos($options) instead, I get the
> error:
> Fatal error: Class 'FooFilesSource' not found in app/models/
> foo_files.php on line 11
>
> How do I invoke a function in the datasource, from a model?
>
> Thanks!

-- 
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
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to