Hi, I have a few comments: You should not have to mess with "set_include_path" at all.
You never assign the controller to the $controller property. You assign it to $this->data for some reason. Even if you change that so that $this->controller is the controller you don't do database calls to controllers, which is what you are trying. The component need a reference to a model or at least a hint as to which model it should query. Then again, if you are just going to do a completely manual and hard-coded query you don't need any model, only the dbo. But that is definitely step 2 (or 3). A side note: I'd also choose to create the cached index in the applications tmp folder to eliminate any problems with deployment. Like this (or in some sub-folder): $index = Zend_Search_Lucene::create(TMP.'my-index'); On Mar 12, 5:13 am, DoughBasher <[email protected]> wrote: > I have been, for days, trying to add Zend_lucene search to my cake > site. It works perfectly when I use it in my controller (i.e. without > the component) but I am not having much luck turning it into a > component so that it will be available to all of my controllers. This > is a site-wide search and the form is to appear on every page. > > The error I am getting is: Fatal error: Call to a member function query > () on a non-object in C:\wamp\www\test\app\controllers\components > \lucene.php on line 19 > (The file lucene.php is shown in section 3, below.) > > I realise that this is likely to be more of a PHP error than a cake > one, but I am getting the error, I believe, because of CakePHP's file > structure and that I have forgotten to do something in the component > or vendor sections (making it very much a Cake issue, for me). > > Below is what I've done. > > I have extracted the Zend library files into the vendors folder so the > structure is: > 1) > - app/vendors/Zend/Search/Lucene/ > - app/vendors/Zend/Search/Lucene.php > - app/vendors/Zend/Search/Exception.php > > 2) > In my controller that I want to access this component, I have declared > var $components = array('lucene'); > > 3) > The component, lucene.php, contains the following code: > > <?php > $path = APP.'/vendors'; > set_include_path(get_include_path() . PATH_SEPARATOR . $path); > App::import('Vendor','lucene',array('file'=>'Zend/Search/ > Lucene.php')); > > class LuceneComponent extends Object > { > var $controller = null; > > function startup(&$controller) > { > $this->data = $controller; > } > > function build() > { > $index = Zend_Search_Lucene::create('/tmp/my-index'); > //***** The line below causes the error****** > $company_rs = $this->controller->query('MY VALID > SELECT > STATEMENT'); > //... more irrelevant code not included > } > } > ?> > The query itself (not shown) is valid, so it's not the SQL. > What have I done, or not done, to get this to work. > > Any help would be much appreciated. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
