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
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 '
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
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
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
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:
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.
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
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' =>
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
>>
>>
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
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
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
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
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
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.
>
>
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
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
; 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.
>
> >
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');
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
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.
>
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.
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
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
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
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
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
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
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()
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
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
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
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
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
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
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
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
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
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
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
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;
> 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->
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
44 matches
Mail list logo