hi AD7six,
I posted my solution ...but not sure why its not here..I will post it
again if fails to appear...but after you mentioned about countercache,
I checked into it...it seems I wont be able to use countercache..as I
just don't to calculate total number of songs by each singer...but
total nu
hi AD7six,
this was the best solution I could think of...can you think this can be
further optimized.. I am not sure about counterCache...I will looking
into ...please let me know if you can think this query can be further
optimized...
Regards,
bingo
SOLUTION==
Hi Bingo,
The key to being able to sort is to get the findAll method (or if that
turns out to not be direcltly possible your custom, but exactly the
same format, sql query) to return you what you want rather than a sql
query followed by a php for each loop.
http://groups-beta.google.com/group/c
hi bakers
(especially AD7six and Christoph)
Now, I did find a solution for specifying the query, but getting a
trouble on how to set pagination. I want to set the pagination on name,
count or id
any ideas on how to do to set pagination.
Regards
--~--~-~--~~~--
Thanks AD7six and Christoph,
got everything working with minimum SQL and in a clean way...
For others reference.this was my solution
$criteria = array('user_id' => "{$userid}"); // basicaly get id of the
user
$songlist = $this->SongsUser->findAll($criteria, array('song_id'),
null, null, -1
Ps.
Forgot to include this link, which might be useful in creating the
constraint on your Song model:
http://cakephp.org/pastes/show/abc17e6d6081dc7c2f91540668447d9f
HTH,
AD7six
Please note:
The manual/bakery is a good place to start any quest for info.
The cake search (at the time of writing) e
Hi Bingo,
The sql above seems a bit overcomplex, maybe I'm mising something.
Why not:
Create a list of unique Singer/Artist Ids from the song model
Use that list of Ids.
?
To create the singer id list would be something like $data =
$this->Singer->Song->findAll(null,array("DISTINCT
'Song.sing
hi,
Thanks to Christoph. I found a solution but wondering is there any
better way to get rid of this long SQL query. Its fine for me to have a
multistep procedure
$query = <<< SQL
select
Users.id as user_id,
Users.name as user_name,
Singers.id as singer_id,
Singers.name as singer_name,
Hi Christoph,
Thanks for the query. I got it working.
About your question...It is not necessary to fetch all the data at
onceactually I was expecting a multistep procedure...the way it
will be going to work is that the user clicks on button (title "Show
singers") and then in the view a list
Hello again :-)
Ok, I think I understand, misinterpreted your question.
I am not sure, if this is the best solutioin (honestly I don't think
so), but you could do a custom query
... in the UsersController:
_
$query = <<< SQL
select
Users.id as use
Hi Christoph,
Thanks for the reply. But I am trying to extract "unique singers" based
on the songs in the library of the user. In the above result, I will
get duplicate values for singers and I will need check for duplication
at PHP level. Isn't there any way to specify a query that determines
th
Hello Bingo,
tried the whole scenario:
// in the UsersController
...
...
$data = $this->User->findAll();
$this->set('data',$data);
...
...
You should get a structure like this:
_
Array
(
[0] => Array
(
[User] => Array
(
Hmm, posted an answer ... but it does not appear?!?!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, s
Hi Bakers,
I am trying to figure out a good way to specify a query. I want to
retrieve all the singers based on the songs that a user has in his
library. Here is my database structure
Users
id
name
singer
id
name
songs
id
title
album
singers
14 matches
Mail list logo