Hello all,

I'm looking for a way to filter my query for Subject model which is
has and belongs to Confession model with findall method.
or a way to make this pagination work with custom query.

I'm using cake 1.1

This is a really long question but i hope the answer will be short.
here I start;

when i write findall for confession model  with recursive=1  i get

(Subject is samething  as tag at blogs and everywhere. but i name it
as subject.)


[0] => Array
            [Confession] => Array
                     [id] => 43
                    [title] => çok komik olay
                    [user_id] => 10

            [User] => Array
                    [id] => 10
                    [username] => arasfb
                    [password] => ea8d23ac419b4af0712bc152de5ff8bb

            [Subject] => Array
                    [0] => Array
                            [id] => 1
                            [subject] => Komik
but when i look at automated sql query string made by cake, it first
gets confessions and users tables and makes separate queries to join
'confessions_subjects and subjets tables' to 'confession and user
tables'.
so i can not give a parameter to like ('Subject.id'=>'2')  because
subject table never exists in first query so i get error.

so i write a custom query(someone in this forum wrote very similar
query, i steal this from him/her :) thaks).

$show=5;
$paginationCount = same query below with Count.....
list($order,$limit,$page) = $this->Pagination-
>init(null,null,array('total'=>$paginationCount[0][0]['count'],'show'=>
$show,'sortBy'=>'Confession.entrydate','direction'=>'DESC'));
$page = $this->fixPage($show, $page);

$this->Confession->query("SELECT DISTINCT * FROM confessions AS
Confession LEFT JOIN confessions_subjects AS pt ON confession.id =
pt.confession_id
LEFT JOIN subjects AS Subject ON Subject.id = pt.subject_id
LEFT JOIN users AS User ON User.id=Confession.user_id
WHERE 1=1 and Subject.id=".$id." ORDER BY Confession.entrydate
DESC"));

this works fine for filtering query but i cannot made it work with
pagination.

i follow the tutorial and made that page_fix stuff and yes it works to
fix page numbers at custum queries but doesn't limit query.
when  i wrote LIMIT 5 at end of my query it limits as expected but
changing page does nothing.

I'm waiting for your help,
thanks.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to