Hey, i've been trying to set my data model/database up to use the cake
built in querying system, with partial success. I've temporarily
written my own queries, except then i need to reformat the returned
array to make it useful.

I have several tables

posts
posts_users
users
wikis
tags
tags_wikis
photos

The logic i have setup is:

posts
 HABTM users
 hasMany wikis

wikis
 belongsTo users
 belongsTo posts
 HABTM tags
 hasMany photos

users
 hasMany posts
 hasMany wikis

tags
 HABTM wikis

photos
 belongsTo wikis

My goal is to do a search on post and it returns (in chunks of 5 for
pagination) all the wikis and users, plus for each wiki it returns the
tags and photos. The databases seem to communicate okay, but some of
the parameters in my associations are completely ignored.

For example i use the following statement in the controller:
$this->Post->findAll(null, null, null, "5");

var $hasAndBelongsToMany = array(
'User' => array(
'className'   => 'User',
'joinTable'     => 'posts_users',
'foreignKey'  => 'post_id',
'conditions'  => '',
'order'       => '',
'limit'       => '',
'dependent'   => true,
'exclusive'   => false,
'finderSql'   => '',
'deleteQuery'   => ''
)
);

// only return the most recent wiki
var $hasMany = array(
'Wiki' => array(
'className'   => 'Wiki',
'conditions'  => '',
'order'       => 'Wiki.created DESC',
'limit'       => '1',
'foreignKey'  => 'post_id',
'dependent'   => true,
'exclusive'   => false,
'finderSql'   => ''
)
);

Now when i do a find or findall cake returns
array(
Post = array of post row
Wiki = array(
   0 = array of 1st wiki row
   1 = array of 2nd wiki row
   2 = array of 3rd wiki row
  ... etc)
User = array(
   0 = array of 1st wiki row
   1 = array of 2nd wiki row
   2 = array of 3rd wiki row
  ... etc)
)

But in my association, i asked it to only return one wiki. My first
question then, is how do i get my association to only return 1 wiki,
while returning 5 posts?

thanks
-matt


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to