Re: RequestAction with pagination ?

2008-03-09 Thread Lisa B

> I get undefined variable $paginate...

I dunno if this helps but the var name in the view is $paginator (not
$paginate) like in

sort('id');?>

--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to search a hasAndBelongsToMany related table?

2008-03-09 Thread Lisa B

maybe like:

this->Users->TeamsUser->findAll(array('Team.league_id' => 1));

as in:

http://www.cricava.com/blogs/index.php?blog=6&title=modelizing_habtm_join_tables_in_cakephp_&more=1&c=1&tb=1&pb=1

--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: override foreign key name with HABTM

2008-03-07 Thread Lisa B

Thank you that worked!  I really appreciate that and thanks for
enlightening me about  'with'.

I have a follow up question pretty please:  now I'm having the same
problem with trying to find all terms in a given  context.  I'm trying
to use 'with' but it doesn't seem to behave or I'm missing something..

This:

$joinRecords = $this->Term->ContextsTerm-
>findAll(array('ContextsTerm.context_no' => 6));

it creates this query which fails on trying to find the wrong key
names

SELECT `ContextsTerm`.`context_no`, `ContextsTerm`.`term_no`,
`Context`.`no`, `Context`.`name`, `Context`.`description`,
`Term`.`no`, `Term`.`term`, `Term`.`term_nice`, `Term`.`display`,
`Term`.`import_date` FROM `contexts_terms` AS `ContextsTerm` LEFT JOIN
`contexts` AS `Context` ON (`ContextsTerm`.`context_id` =
`Context`.`no`) LEFT JOIN `terms` AS `Term` ON
(`ContextsTerm`.`term_id` = `Term`.`no`) WHERE
`ContextsTerm`.`context_no` = 6

it's like this:

class ContextsTerm extends AppModel {
var $name = 'ContextsTerm';
var $belongsTo = array('Context','Term');
}

class Term extends AppModel {
var $name = 'Term';
var $displayField = 'term_nice';
var $primaryKey = 'no';

var $hasAndBelongsToMany = array(
'Context' => array(
'joinTable' => 'contexts_terms',
'foreignKey'   => 'term_no',
'associationForeignKey' => 'context_no',
'with' => 'ContextsTerm'
)
);
}

class Context extends AppModel
{
var $name = 'Context';
var $displayField = 'name';
var $primaryKey = 'no';

var $hasAndBelongsToMany = array(
'Term' => array(
'joinTable' => 'contexts_terms',
'foreignKey'   => 'context_no',
'associationForeignKey' => 'term_no',
'with' => 'ContextsTerm'
)
  );
}


--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Propagating query string with paginator?

2008-03-06 Thread Lisa B

you can add stuff to the url of sort and nex/prev links with
paginator, it's in the api, so a sort table header maybe something
like:

$paginator->sort('no','Media.no',array('url'=>array($term)));

hope that helps..

--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



override foreign key name with HABTM

2008-03-06 Thread Lisa B

In my project I can't use the default 'id' name for primary key
fields, I have to use 'no'.  I have to change a cake I already baked
from using 'no' to 'id' everywhere.  I hadn't customized it much and I
could easily change the database and everywhere I could see in the
views and models, and most pages work perfectly as before, except this
one where the join is a HABTM.

It is a dictionary app where a term can have many contexts and a
context many terms.  The query that is failing when I visit
/contexts/view/5 is still looking for an '_id' field on the join, like
this:

Query: SELECT `Term`.`no`, `Term`.`term`, `Term`.`term_nice`,
`Term`.`display`, `Term`.`import_date`, `ContextsTerm`.`context_no`,
`ContextsTerm`.`term_no` FROM `terms` AS `Term` JOIN `contexts_terms`
AS `ContextsTerm` ON (`ContextsTerm`.`context_no` IN (5) AND
`ContextsTerm`.`term_id` = `Term`.`no`)

In the view I'm not even trying to view the list of terms, I removed
that section from the view that it baked, so I wish it weren't trying
to do that query, but it's just a warning not an error, but that query
crops up and breaks on another page as well where I do need it and I
don't know where to look..  Perplexed, I am new to cake, thanks..

term.php:
class Term extends AppModel {
var $name = 'Term';
var $displayField = 'term_nice';
var $primaryKey = 'no';

var $hasAndBelongsToMany = array('Context' =>
array('className'=> 'Context',
 'joinTable' => 'contexts_terms',
 'conditions'   => '',
 'order'=> '',
 'foreignKey'   => 'term_no'
   )
);
}

context.php:
class Context extends AppModel {
var $name = 'Context';
var $displayField = 'name';
var $primaryKey = 'no';

var $hasAndBelongsToMany = array('Term' =>
array('className'=> 'Term',
 'joinTable' => 'contexts_terms',
 'conditions'   => '',
 'order'=> '',
 'foreignKey'   => 'context_no'
)
);
}


// I have modeled this so I can get easy pagination on another page
which is also broken on that join
class ContextsTerm extends AppModel {
var $belongsTo = array('Context','Term');
var $primaryKey = 'context_no';
}

--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---