Re: Combining Zend_lucene, Vendors, Component does not my cake make
Thanks Erik. I'll definitely have a look there. This reinventing the wheel thing is getting old (and so am I). Regards, Dough! On Mar 13, 2:05 am, Esoteric wrote: > If you look at the application that runs the book.cakephp.org, our > wonderful cakephp devs have already made using Zend_Lucene pretty > simple, takes a little bit of work to decipher how ot use it, but I am > using it onwww.tribaloutpost.comand it works phenominally. If I have > time I might write it up. > > -Erik > > On Mar 12, 1:26 pm, DoughBasher wrote: > > > Brendon, > > > Will do. It may be a cold day in hell before then, but once I have > > annoyed the guys on IRC enough to get the solution, I will post it. > > Of course, if you get it to work don't hesitate to fling it my way. > > > Thanks > > > Dough! > > > On Mar 12, 9:17 pm, Brendon Kozlowski wrote: > > > > If you end up getting this working, I'd love to hear how you managed > > > to do it, if you have the time! > > > > On Mar 12, 12:13 am, DoughBasher 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: > > > > > > > > $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.- Hide quoted text - > > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com 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?hl=en -~--~~~~--~~--~--~---
Re: Combining Zend_lucene, Vendors, Component does not my cake make
If you look at the application that runs the book.cakephp.org, our wonderful cakephp devs have already made using Zend_Lucene pretty simple, takes a little bit of work to decipher how ot use it, but I am using it on www.tribaloutpost.com and it works phenominally. If I have time I might write it up. -Erik On Mar 12, 1:26 pm, DoughBasher wrote: > Brendon, > > Will do. It may be a cold day in hell before then, but once I have > annoyed the guys on IRC enough to get the solution, I will post it. > Of course, if you get it to work don't hesitate to fling it my way. > > Thanks > > Dough! > > On Mar 12, 9:17 pm, Brendon Kozlowski wrote: > > > > > If you end up getting this working, I'd love to hear how you managed > > to do it, if you have the time! > > > On Mar 12, 12:13 am, DoughBasher 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: > > > > > > $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.- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com 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?hl=en -~--~~~~--~~--~--~---
Re: Combining Zend_lucene, Vendors, Component does not my cake make
Hi Martin, Thanks for your comments. I was trying to cobble together info from various sources on the net by brave folks who attempted the Lucene-Cake bastardisation route before me. I agree with the 'set_include_path' It was the latest attempt after a long series of attempts to get it to work. It returned the least number of errors and, at that point in time, it was going to do for me. However, it kept cropping up when smarter people than me write about Zend and Cake (as either set_include_path or ini_set ('include_path') [1][2] Jonathan Snook actually added it to his core.php :O [3] As for assigning the controller to the $controller, I was, once again, following the wisdom of others. Golding's book he stated: "[U]se the startup() function to instantiate the controller object. Then all functions in the controller can use $this->controller to access anything in the parent controller. function startup(&$controller) { $this->controller = $controller; } "[4] Doing DB calls to the controller. You're right, I have no idea what I was thinking. It was a brain-fart that stuck and stayed, I believe (not a pretty metaphor, sorry). Finally I totally agree with you on the caching. It is on the cards. I was just trying to get the easy stuff working first. (ha ha ha). Also I realise that a lot of these sources were written when Cake was still a baby and things have changed by leaps and bounds since. Moreover, I am (obviously) new to all this and may have picked up the wrong end of every stick while reading articles on this topic. What I am trying to say is that I am in no way suggesting that these articles I sited here are wrong...just wrong to me :) Thanks again, Martin, for your time. [1] David Golding, 'Beginning CakePHP From Novice to Professional', page 213 (albeit he uses it in the vendor file). [2] http://bakery.cakephp.org/articles/view/integrating-zend-framework-lucene-with-your-cake-application [3] http://snook.ca/archives/php/zend_framework_first_impressions/ [4] David Golding, 'Beginning CakePHP From Novice to Professional', page 206 On Mar 12, 3:54 pm, Martin Westin wrote: > 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 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: > > > > $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** >
Re: Combining Zend_lucene, Vendors, Component does not my cake make
Brendon, Will do. It may be a cold day in hell before then, but once I have annoyed the guys on IRC enough to get the solution, I will post it. Of course, if you get it to work don't hesitate to fling it my way. Thanks Dough! On Mar 12, 9:17 pm, Brendon Kozlowski wrote: > If you end up getting this working, I'd love to hear how you managed > to do it, if you have the time! > > On Mar 12, 12:13 am, DoughBasher 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: > > > > $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 cake-php@googlegroups.com 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?hl=en -~--~~~~--~~--~--~---
Re: Combining Zend_lucene, Vendors, Component does not my cake make
If you end up getting this working, I'd love to hear how you managed to do it, if you have the time! On Mar 12, 12:13 am, DoughBasher 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: > > $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 cake-php@googlegroups.com 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?hl=en -~--~~~~--~~--~--~---
Re: Combining Zend_lucene, Vendors, Component does not my cake make
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 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: > > $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 cake-php@googlegroups.com 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?hl=en -~--~~~~--~~--~--~---