Re: Making a "Complex search"

2011-09-16 Thread CaStarCo
I've solved it making two searches :p , I think there is no way to make complex nested SELECT queries in Cake (and direct SQL is not much better, it's possible, but it's too tricky, ugly and slow). 2011/9/13 WebbedIT > Show us what you have tried so far ... it will be easier to make > sense of

Re: Making a "Complex search"

2011-09-13 Thread WebbedIT
Show us what you have tried so far ... it will be easier to make sense of your SQL or Cake conditions On Sep 12, 9:01 am, CaStarCo wrote: > Hello, I have a doubt about the best way to do a complex search. > > I have a model "Agreements", every agreement entity have a '

Making a "Complex search"

2011-09-12 Thread CaStarCo
Hello, I have a doubt about the best way to do a complex search. I have a model "Agreements", every agreement entity have a 'state' field, wich can have the 'expired' value, I want to show all the agreements that haven't expired, but not the expired ones... wit

Re: Complex Search

2011-01-26 Thread Jon Bennett
Hi Steve, Sounds like you need to use the 'joins' param in a find and skip containable, here's the manual page http://book.cakephp.org/view/872/Joining-tables hth Jon On 26 January 2011 10:37, Steve wrote: > Unfortunately using Containable did not work as I would have hoped. > > 1. I could not

Re: Complex Search

2011-01-26 Thread Steve
Unfortunately using Containable did not work as I would have hoped. 1. I could not get containable to do an inner join on the data. This is because the actual relationships between the Book, Category and Author tables are many-to-many so it performs a search on the books then a search on the autho

Re: Complex Search

2011-01-25 Thread Steve
Having just found this... you are right it is exactly what I need. Thanks for this pointer. As for my code... I have spent the day tidying it up as each book has 2 many to many relationships ( Categories and Authors ) so it was getting in a mess. On Tue, 2011-01-25 at 14:35 -0500, cricket wrote:

Re: Complex Search

2011-01-25 Thread Steve
Hi Cricket... Could you describe what you mean in more detail ? I have not used Containable before On Tue, 2011-01-25 at 14:35 -0500, cricket wrote: > On Tue, Jan 25, 2011 at 9:00 AM, Steve wrote: > > I have solved this by overriding the paginate and paginateCount methods > > in my Book model.

Re: Complex Search

2011-01-25 Thread cricket
On Tue, Jan 25, 2011 at 9:00 AM, Steve wrote: > I have solved this by overriding the paginate and paginateCount methods > in my Book model. Instead of that, you could use Containable. And you don't need to have the else block in the index action. Declare $paginate as a class var, then add the 'c

Re: Complex Search

2011-01-25 Thread Steve
I have solved this by overriding the paginate and paginateCount methods in my Book model. /** * Overridden paginate */ function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null, $extra = array()) { if( $this->searchCategories){ $this->bindModel(array('hasOne' =>

Re: Complex Search

2011-01-25 Thread Vivi Vivi
Maybe you can use a search engine like SphinxSearch, Solr, ZendLucene. On Tue, Jan 25, 2011 at 3:26 PM, Vivi Vivi wrote: > Maybe we can use a search engine like SphinxSearch, Solr, ZendLucene. > > > On Tue, Jan 25, 2011 at 1:22 PM, Steve wrote: > >> Can anyone help with this ? >> >> Steve >> >>

Re: Complex Search

2011-01-25 Thread Vivi Vivi
Maybe we can use a search engine like SphinxSearch, Solr, ZendLucene. On Tue, Jan 25, 2011 at 1:22 PM, Steve wrote: > Can anyone help with this ? > > Steve > > On Sun, 2011-01-23 at 15:22 +, Steve wrote: > > I have a database with the following tables. > > > > book - Holds id, title, descri

Re: Complex Search

2011-01-25 Thread Steve
Can anyone help with this ? Steve On Sun, 2011-01-23 at 15:22 +, Steve wrote: > I have a database with the following tables. > > book - Holds id, title, description, publisher ... > author - Holds id, name > books_author - Holds id, book_id, author_id > > So a many-to-many relationship on

Complex Search

2011-01-23 Thread Steve
I have a database with the following tables. book - Holds id, title, description, publisher ... author - Holds id, name books_author - Holds id, book_id, author_id So a many-to-many relationship on the book and author as one book can have many authors and one author can have many books. To sea

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-05 Thread AD7six
On May 5, 3:40 am, Kei Simone wrote: > Hi Andy, > > so in conclusion, i should get into the habit of installing these cake > files as plugins. > > Thank you. > > I didn't try your one_query cause i tried reading it but i dont quite > understand how to use it. There's not much to figure out if y

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Hi Andy, so in conclusion, i should get into the habit of installing these cake files as plugins. Thank you. I didn't try your one_query cause i tried reading it but i dont quite understand how to use it. Hope you dont mind. however, you have been the most helpful to me so far in pointing me t

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread AD7six
On May 4, 7:19 pm, Kei Simone wrote: > Hi Andy, > > i got it to work using Linkable. as well as you suggested by using > bindModel which is slightly more readble than joins. > > though i think linkable is really darn short and it looks good. > > I am sorry, i apologise that i misunderstood. > >

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Hi Andy, i got it to work using Linkable. as well as you suggested by using bindModel which is slightly more readble than joins. though i think linkable is really darn short and it looks good. I am sorry, i apologise that i misunderstood. I thought both the linkable and the onequery are the sam

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread AD7six
On May 4, 4:24 pm, Kei Simone wrote: > Hi AD7six, > > i apologise if i have asked a question that can be easily answered if > i looked a little more closely. I think you have a misunderstanding of what a plugin is (see the book) and are mixing the usage of two different behaviors together - se

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
; b) i REALLY REALLY want to get better at cakephp hence understanding > > > > and studying Containable a core behavior is essential > > > > > since my joins is already working i have less inclination to try out > > > > the find all with recursive 2. > > >

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Hi AD7six, i apologise if i have asked a question that can be easily answered if i looked a little more closely. but i am having some problems. Here it is: i tried this $this->Behaviors->attach('OneQuery'); $this->User->Behaviors->attach('OneQuery');

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Andrei Mita
ALLY want to get better at cakephp hence understanding > > > and studying Containable a core behavior is essential > > > > > since my joins is already working i have less inclination to try out > > > the find all with recursive 2. > > > > > 2) my merchan

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
to them EACH. > > > Recursive 2 would be mean retrieving a lot of data. I am assuming this > > from the docs i read in book.cakephp.org esp the articles on > > Containable. in fact this is the very reason why Containable was > > promoted to solve this very same issue. >

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Andrei Mita
g. then i shall try it out. > but only if you give me exact details. > > I am a 1 month old in terms of cake usage despite reading the docs > extensively i may still need quite a bit of hand holding. > > 3) i want to find the first datarow that matches the condition not > ALL.

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Hi Jeremy, thank you for answering. I agree with you that it would be silly of me to keep emphasizing to do the find from merchant. i would readily accept a solution that does it elegantly even if the find starts from another model. For instance, i tried out Jon's example code and subsequently p

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
would still stand. I am truly sorry if what i said is rude or offends you. At work and at home, i have been labelled as harsh and insensitive. At times i wonder if i am autistic. But this (obsessive) search to understand how the heck to get complex search right and get a true understanding of

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Andrei Mita
Was that a sarcastic question? On Tue, May 4, 2010 at 3:13 PM, sphereweb wrote: > I would like to see your example that gets the data from 4-5 tables :) > > On May 4, 7:49 am, Andrei Mita wrote: > > I'm having a hard time understanding your problem, probably it's just me, > > I'm not having a g

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread AD7six
On May 4, 2:13 pm, sphereweb wrote: > I would like to see your example that gets the data from 4-5 tables :) There's only 1 test case in it but you can see usage here: http://github.com/AD7six/mi/blob/master/tests/cases/behaviors/one_query.test.php Although the single test case is calling oneQ

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread sphereweb
I would like to see your example that gets the data from 4-5 tables :) On May 4, 7:49 am, Andrei Mita wrote: > I'm having a hard time understanding your problem, probably it's just me, > I'm not having a good time at work. > > So, if you have 4 tables all linked together (it doesn't matter if Sho

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Andrei Mita
I'm having a hard time understanding your problem, probably it's just me, I'm not having a good time at work. So, if you have 4 tables all linked together (it doesn't matter if Shop links to User through Merchant), than my guess is that Containable would be the quickest way to get the data you wan

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Jeremy Burns
The find does not have to be done from the Merchant model. If the models are related if sometimes makes sense to hop across to another model to start the find from there (I often do this). If it makes more sense to start it from, say, the User model, then you can do $this->Merchant->User->find()

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Sorry for the continuous replies. Just realised that my scenario was not complete enough. User hasOne Merchant (so Merchant belongsTo User and user_id inside merchants table) Shop hasMany Merchant (so Merchant belongsTo Shop and shop_id inside merchants table) Shop hasMany Domain (so Domain belon

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
i have the following for my cake 1.3: User hasOne Merchant (so Merchant belongsTo User) Shop hasMany Merchant (so Merchant belongsTo Shop as well.) Shop hasMany Domain (so Domain belongsTo Shop.) i need to use Merchant model to do a find of all 4 related data. i need to find the first datarow th

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Hi Andy, 1) it is precisely i have tried it see my ultra long post with all the sql queries and result sets that i know containable is not for me. i am still looking to see if your linkable behavior is what i need. however, i am quite noob, so i dont know how to use your one_query even though i

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread AD7six
On May 4, 9:45 am, Kei Simone wrote: > Your statement on the right join i do not quite understand. > > Which find statement are you explaining on? > > Thank you for being enthusiastic to clear my doubts. Kei - you don't need to reply to each question individually - you can reply to many message

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Your statement on the right join i do not quite understand. Which find statement are you explaining on? Thank you for being enthusiastic to clear my doubts. On May 3, 3:55 pm, AD7six wrote: > On May 2, 1:45 pm, Jon Bennett wrote: > > > > > > > > i need to use Merchant model to do a find of al

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
I dont like recursive because i suspect that it will return all the related model data of a certain level. i only want very specific model data. or rather data from specific models. On May 3, 3:35 pm, Andrei Mita wrote: > Or here is another idea. Make a find('all') query with $recursive = 2 and

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Is the bindModel any better than the joins? http://book.cakephp.org/view/1047/Joining-tables the joins are working for me. however of course the reason why i am asking so many quesitons is to increase my working knowledge of Cake for what works and what does not. thank you. On May 3, 3:52 pm, A

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-03 Thread AD7six
On May 2, 1:45 pm, Jon Bennett wrote: > > i need to use Merchant model to do a find of all 4 related data. > > notice that Domain is the only one NOT directly related to Merchant. > > > i tried this in a method inside Merchant model: > > > $this->Behaviors->attach('Containable'); > > $this->User

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-03 Thread AD7six
On May 3, 7:02 am, Kei Simone wrote: > Hi i did this > > $this->Behaviors->attach('Containable'); >                 $this->User->Behaviors->attach('Containable'); >                 $this->Shop->Behaviors->attach('Containable'); >                 $this->Shop->Domain->Behaviors->attach('Containabl

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-03 Thread Andrei Mita
Or here is another idea. Make a find('all') query with $recursive = 2 and see how much information is there that you don't need. On Mon, May 3, 2010 at 10:33 AM, Andrei Mita wrote: > Simone, > > Containable is extremely powerful. I am just amazed how little time it > takes me to write complex q

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-03 Thread Andrei Mita
Simone, Containable is extremely powerful. I am just amazed how little time it takes me to write complex queries. Give me the structure of the tables and an example of what do you want to retrieve from them and I might be able to help you around. On Mon, May 3, 2010 at 8:02 AM, Kei Simone wrot

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-02 Thread Kei Simone
Hi i did this $this->Behaviors->attach('Containable'); $this->User->Behaviors->attach('Containable'); $this->Shop->Behaviors->attach('Containable'); $this->Shop->Domain->Behaviors->attach('Containable'); $this->recursive = -1;

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-02 Thread Jon Bennett
> i need to use Merchant model to do a find of all 4 related data. > notice that Domain is the only one NOT directly related to Merchant. > > i tried this in a method inside Merchant model: > > $this->Behaviors->attach('Containable'); > $this->User->Behaviors->attach('Containable'); > $this->Shop->

The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-02 Thread Kei Simone
Hi, i have the following for my cake 1.3: User hasOne Merchant (so Merchant belongsTo User) Shop hasMany Merchant (so Merchant belongsTo Shop as well.) Shop hasMany Domain (so Domain belongsTo Shop.) i need to use Merchant model to do a find of all 4 related data. notice that Domain is the only