HABTM again!

2011-07-21 Thread localhost
Hi everyone,

I have being trying to solve this for the last 4 hours with no luck.

basically I have the following tables

users
links
users_links

Basically I'm trying to get the below query to run using find('all')
and paginate (I'm running this inside UserController)

SELECT Links.id,Links.Title FROM users,links,users_links WHERE
user.id=1 AND user.id=users_links.user_id AND
users_links.link_id=links.id AND users_links.index=1

(see the above sql users_links.index=1).


how to get this working ?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: HABTM again!

2011-07-21 Thread Jeremy Burns | Class Outfit
If you have defined a HABTM relationship your joining table should be 
links_users (i.e. the tables are in alphabetical order).

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 21 Jul 2011, at 16:26, localhost wrote:

 Hi everyone,
 
 I have being trying to solve this for the last 4 hours with no luck.
 
 basically I have the following tables
 
 users
 links
 users_links
 
 Basically I'm trying to get the below query to run using find('all')
 and paginate (I'm running this inside UserController)
 
 SELECT Links.id,Links.Title FROM users,links,users_links WHERE
 user.id=1 AND user.id=users_links.user_id AND
 users_links.link_id=links.id AND users_links.index=1
 
 (see the above sql users_links.index=1).
 
 
 how to get this working ?
 
 -- 
 Our newest site for the community: CakePHP Video Tutorials 
 http://tv.cakephp.org 
 Check out the new CakePHP Questions site http://ask.cakephp.org and help 
 others with their CakePHP related questions.
 
 
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
 http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: HABTM again!

2011-07-21 Thread localhost
Sorry I didn't understand your reply

I have defined the relationship


class UsersLink extends AppModel {
var $belongsTo = array(
'Link' = array(
'className' = 'Link',
'foreignKey' = 'link_id',
'conditions' = '',
'fields' = '',
'order' = ''
),
'User' = array(
'className' = 'User',
'foreignKey' = 'user_id',
'conditions' = '',
'fields' = '',
'order' = ''
)
);

}


What do you mean by joining table should be links_users (i.e. the
tables are in alphabetical order)  ?


On Jul 21, 6:31 pm, Jeremy Burns | Class Outfit
jeremybu...@classoutfit.com wrote:
 If you have defined a HABTM relationship your joining table should be 
 links_users (i.e. the tables are in alphabetical order).

 Jeremy Burns
 Class Outfit

 http://www.classoutfit.com

 On 21 Jul 2011, at 16:26, localhost wrote:







  Hi everyone,

  I have being trying to solve this for the last 4 hours with no luck.

  basically I have the following tables

  users
  links
  users_links

  Basically I'm trying to get the below query to run using find('all')
  and paginate (I'm running this inside UserController)

  SELECT Links.id,Links.Title FROM users,links,users_links WHERE
  user.id=1 AND user.id=users_links.user_id AND
  users_links.link_id=links.id AND users_links.index=1

  (see the above sql users_links.index=1).

  how to get this working ?

  --
  Our newest site for the community: CakePHP Video 
  Tutorialshttp://tv.cakephp.org
  Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help 
  others with their CakePHP related questions.

  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com For more options, visit this group 
  athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: HABTM again!

2011-07-21 Thread localhost
This is one way I found it to be working with find('all') but not with
paginate ( due to the select count)


 $this-User-recursive = -1;
 $options['joins'] = array(
array('table' = 'users_links',
'alias' = 'UsersLink',
'type' = 'inner',
'conditions' = array(
'User.id = UsersLink.user_id',
'UsersLink.inbox = 1'
)
),
array('table' = 'links',
'alias' = 'Link',
'type' = 'inner',
'conditions' = array(
'UsersLink.link_id = Link.id'
)
)
);

$options['fields' ] = array('Link.id', 'Link.title');
$inbox = $this-User-find('all', $options);

What do you think?


On Jul 21, 6:31 pm, Jeremy Burns | Class Outfit
jeremybu...@classoutfit.com wrote:
 If you have defined a HABTM relationship your joining table should be 
 links_users (i.e. the tables are in alphabetical order).

 Jeremy Burns
 Class Outfit

 http://www.classoutfit.com

 On 21 Jul 2011, at 16:26, localhost wrote:







  Hi everyone,

  I have being trying to solve this for the last 4 hours with no luck.

  basically I have the following tables

  users
  links
  users_links

  Basically I'm trying to get the below query to run using find('all')
  and paginate (I'm running this inside UserController)

  SELECT Links.id,Links.Title FROM users,links,users_links WHERE
  user.id=1 AND user.id=users_links.user_id AND
  users_links.link_id=links.id AND users_links.index=1

  (see the above sql users_links.index=1).

  how to get this working ?

  --
  Our newest site for the community: CakePHP Video 
  Tutorialshttp://tv.cakephp.org
  Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help 
  others with their CakePHP related questions.

  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com For more options, visit this group 
  athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: HABTM again!

2011-07-21 Thread Jeremy Burns | Class Outfit
I think you are not following the conventions, are making life difficult for 
yourself and should read the guide.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 21 Jul 2011, at 17:05, localhost wrote:

 Sorry I didn't understand your reply
 
 I have defined the relationship
 
 
 class UsersLink extends AppModel {
   var $belongsTo = array(
   'Link' = array(
   'className' = 'Link',
   'foreignKey' = 'link_id',
   'conditions' = '',
   'fields' = '',
   'order' = ''
   ),
   'User' = array(
   'className' = 'User',
   'foreignKey' = 'user_id',
   'conditions' = '',
   'fields' = '',
   'order' = ''
   )
   );
 
 }
 
 
 What do you mean by joining table should be links_users (i.e. the
 tables are in alphabetical order)  ?
 
 
 On Jul 21, 6:31 pm, Jeremy Burns | Class Outfit
 jeremybu...@classoutfit.com wrote:
 If you have defined a HABTM relationship your joining table should be 
 links_users (i.e. the tables are in alphabetical order).
 
 Jeremy Burns
 Class Outfit
 
 http://www.classoutfit.com
 
 On 21 Jul 2011, at 16:26, localhost wrote:
 
 
 
 
 
 
 
 Hi everyone,
 
 I have being trying to solve this for the last 4 hours with no luck.
 
 basically I have the following tables
 
 users
 links
 users_links
 
 Basically I'm trying to get the below query to run using find('all')
 and paginate (I'm running this inside UserController)
 
 SELECT Links.id,Links.Title FROM users,links,users_links WHERE
 user.id=1 AND user.id=users_links.user_id AND
 users_links.link_id=links.id AND users_links.index=1
 
 (see the above sql users_links.index=1).
 
 how to get this working ?
 
 --
 Our newest site for the community: CakePHP Video 
 Tutorialshttp://tv.cakephp.org
 Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help 
 others with their CakePHP related questions.
 
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com For more options, visit this group 
 athttp://groups.google.com/group/cake-php
 
 -- 
 Our newest site for the community: CakePHP Video Tutorials 
 http://tv.cakephp.org 
 Check out the new CakePHP Questions site http://ask.cakephp.org and help 
 others with their CakePHP related questions.
 
 
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
 http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: HABTM again!

2011-07-21 Thread gremlin
What is being said is that you have some conventions you didn't
follow. As a result, you are writing overly-complicated code to handle
what should be automatic within the framework.

Do this:

1) move / rename your users_links table and data to a links_users
table inside mysql.
2) remove completely the model for your join table - the UsersLink
model.
3) define a normal habtm relationship between the User model and the
Link model.
4) read the manual before you start another project - all of this is
clearly explained in many translations.

On Jul 21, 10:45 am, Jeremy Burns | Class Outfit
jeremybu...@classoutfit.com wrote:
 I think you are not following the conventions, are making life difficult for 
 yourself and should read the guide.

 Jeremy Burns
 Class Outfit

 http://www.classoutfit.com

 On 21 Jul 2011, at 17:05, localhost wrote:







  Sorry I didn't understand your reply

  I have defined the relationship

  class UsersLink extends AppModel {
     var $belongsTo = array(
             'Link' = array(
                     'className' = 'Link',
                     'foreignKey' = 'link_id',
                     'conditions' = '',
                     'fields' = '',
                     'order' = ''
             ),
             'User' = array(
                     'className' = 'User',
                     'foreignKey' = 'user_id',
                     'conditions' = '',
                     'fields' = '',
                     'order' = ''
             )
     );

  }

  What do you mean by joining table should be links_users (i.e. the
  tables are in alphabetical order)  ?

  On Jul 21, 6:31 pm, Jeremy Burns | Class Outfit
  jeremybu...@classoutfit.com wrote:
  If you have defined a HABTM relationship your joining table should be 
  links_users (i.e. the tables are in alphabetical order).

  Jeremy Burns
  Class Outfit

 http://www.classoutfit.com

  On 21 Jul 2011, at 16:26, localhost wrote:

  Hi everyone,

  I have being trying to solve this for the last 4 hours with no luck.

  basically I have the following tables

  users
  links
  users_links

  Basically I'm trying to get the below query to run using find('all')
  and paginate (I'm running this inside UserController)

  SELECT Links.id,Links.Title FROM users,links,users_links WHERE
  user.id=1 AND user.id=users_links.user_id AND
  users_links.link_id=links.id AND users_links.index=1

  (see the above sql users_links.index=1).

  how to get this working ?

  --
  Our newest site for the community: CakePHP Video 
  Tutorialshttp://tv.cakephp.org
  Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp 
  others with their CakePHP related questions.

  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com For more options, visit this group 
  athttp://groups.google.com/group/cake-php

  --
  Our newest site for the community: CakePHP Video 
  Tutorialshttp://tv.cakephp.org
  Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help 
  others with their CakePHP related questions.

  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com For more options, visit this group 
  athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


HABTM... again

2011-03-02 Thread János Vasbányai
Hello!
I'm trying to get some data using habtm.
here is the code:

$this-Article-bindModel(array('hasOne'=array('ArticlesTag')));
$tags = $this-Article-Tag-
find('list',array('conditions'=array('ArticlesTag.article_id'=
$id)));

The source is from the manual.
Now the error:

Warning (512): SQL Error: 1054: Unknown column
'ArticlesTag.article_id' in 'where clause' [APP\cake\libs\model
\datasources\dbo_source.php, line 681]
Query: SELECT `Tag`.`id`, `Tag`.`name` FROM `tags` AS `Tag`   WHERE
`ArticlesTag`.`article_id` = 36

I just can't figure out what's wrong. What am i missing? i read the
manual + some blog entries about habtm but i don't feel like i'm
closer to the goal.

Another thing: When one record from articles table is deleted
(trough cake), all of the joins are deleted too. Help me!

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


RE: HABTM... again

2011-03-02 Thread Krissy Masters
For 1.2 but still applies:

http://marianoiglesias.com.ar/cakephp/modelizing-habtm-join-tables-in-cakeph
p-1-2-with-and-auto-with-models/

or

http://nuts-and-bolts-of-cakephp.com/2008/07/03/notes-on-cakephp-habtm-part-
1-the-basics/

Common mistake is in the name. Filename / classname / singular (plural
mixup).
Also with = some_join_table parameter another option.

K


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Habtm again

2010-04-02 Thread WebbedIT
Which model are you declaring this in? As it should logically be in
Parent or Student, but your controller logic looks as though you're in
Person.  Until I can understand a little more about your models I cant
really offer much assistance.

Paul

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe, reply using remove me as the subject.


Habtm again

2010-04-01 Thread Mateusz Kaczanowski
Hi guys,
I have a little annoying problem.

Habtm declaration:

'ParentsHasStudents' = array(
'className' = 'Parents',
'joinTable' = 'parents_has_students',
'foreignKey' = 'parent_id',
'unique' = false,
'associationForeignKey' = 'student_id'));

And Post Data:

[ParentsHasStudents] = Array
(
[0] = Array
(
[student_id] = 1
)

[1] = Array
(
[student_id] = 5
)

command $this-Person-saveAll($this-data) is ovveriding first
student_id data by UPDATE:

UPDATE `parents_has_students` SET `student_id` = 5, `parent_id` = 299 WHERE
`parents_has_students`.`parent_id` = 299

How correct this return into INSERT?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe, reply using remove me as the subject.


HABTM again

2008-10-23 Thread cem

How can I get the related data in habtm in paginator .

  I have auctions and categories . One auction HABTM category .

 I want to get the auctions which has category with ID :

 $data = $this-paginate('Project' ,array(
 
'Auction.status'='open',
 
'Auction.approved'=1,
 'What wil be here'

   )
);

 Thanks in advance .
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP 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
-~--~~~~--~~--~--~---