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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to