Re: hasMany problem !!

2011-04-25 Thread gremlin
You need to edit your view file. You can do a debug( $variableName )
on the data you are sending to the view. You will notice a different
array structure for hasMany as compared to hasOne.


On Apr 24, 9:34 am, taq taqman...@gmail.com wrote:
 databasehttp://upic.me/i/v4/database.jpg
 book modelhttp://upic.me/i/qp/modelbook.jpg
 book catagorie modelhttp://upic.me/i/an/model.jpg
 view eror messagehttp://upic.me/i/ov/xview.jpg
 i test hasOne and belongsTo between books and bookcats it's no eror
 but i test hasMany i got error in view error message

 On Apr 24, 1:55 pm, Jens Dittrich jdittr...@gmail.com wrote:







  if you expect help, then you shoul consider sharing more information
  about what you have done.

  On 24 Apr., 07:42, taq taqman...@gmail.com wrote:

   I set up a table and try to do hasmany Ee Long says can not find.
   But when put into the back hasone found it simple tight

-- 
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: hasMany problem !!

2011-04-24 Thread Jens Dittrich
if you expect help, then you shoul consider sharing more information
about what you have done.

On 24 Apr., 07:42, taq taqman...@gmail.com wrote:
 I set up a table and try to do hasmany Ee Long says can not find.
 But when put into the back hasone found it simple tight

-- 
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: hasMany problem !!

2011-04-24 Thread taq

database
http://upic.me/i/v4/database.jpg
book model
http://upic.me/i/qp/modelbook.jpg
book catagorie model
http://upic.me/i/an/model.jpg
view eror message
http://upic.me/i/ov/xview.jpg
i test hasOne and belongsTo between books and bookcats it's no eror
but i test hasMany i got error in view error message

On Apr 24, 1:55 pm, Jens Dittrich jdittr...@gmail.com wrote:
 if you expect help, then you shoul consider sharing more information
 about what you have done.

 On 24 Apr., 07:42, taq taqman...@gmail.com wrote:







  I set up a table and try to do hasmany Ee Long says can not find.
  But when put into the back hasone found it simple tight

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


hasMany problem !!

2011-04-23 Thread taq
I set up a table and try to do hasmany Ee Long says can not find.
But when put into the back hasone found it simple tight

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


hasMany Problem

2010-08-11 Thread JuMiFi
Hallo liebe Community,

ich habe eine Frage bzgl. hasMany...

Ich habe ein Model User (users), welches via hasOne u.a. auf
Account (users_accounts) und File (users_files) zugreift.
Ausserdem kann es via hasMany auf Friends (friends) zugreifen.

users_files beinhaltet die Uploads eines Users (Profilepic etc...).
Jetzt würde ich gerne mit $this-User-findById() nicht nur User,
Account, File und Friends bekommen, sondern für die Friends wiederum
ausserdem File aus users_files und Account aus users_account...
Verknüpfungen laufen natürlich jeweils über user(s)_id bzw.
friend_id

Strukturell also so:

User
User[Account]
User[File]
User[Friends]
User[Friends][Account]
User[Friends][File]

Danke für eure Hilfe!

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


Re: hasMany Problem

2010-08-11 Thread Max Dörfler

Hi,

ich bin mir nicht sicher, ob ich das alles richtig verstehe, kannst du 
vielleicht den Code deiner Models (den ganzen hasOne, hasMany, belongsTo 
Kram) schicken? Da du dich scheinbar auch nicht so richtig an die 
Namenskonventionen hältst, ist das übersichtlicher. :)
Weil z.B. eine Friend Relation ja typischerweise User HABTM User 
Relation ist.
Ich denke, wenn die ganzen Relationen ordentlich definiert sind, sollte 
das mit dem richtigen Rekursionslevel out of the box funktionieren.


Und wenn du hier auf englisch fragst, sind die Chancen eine gute Antwort 
zu erhalten wesentlich höher. ;)


Gruß
Max

Am 11.08.2010 10:30, schrieb JuMiFi:

Hallo liebe Community,

ich habe eine Frage bzgl. hasMany...

Ich habe ein Model User (users), welches via hasOne u.a. auf
Account (users_accounts) und File (users_files) zugreift.
Ausserdem kann es via hasMany auf Friends (friends) zugreifen.

users_files beinhaltet die Uploads eines Users (Profilepic etc...).
Jetzt würde ich gerne mit $this-User-findById() nicht nur User,
Account, File und Friends bekommen, sondern für die Friends wiederum
ausserdem File aus users_files und Account aus users_account...
Verknüpfungen laufen natürlich jeweils über user(s)_id bzw.
friend_id

Strukturell also so:

User
User[Account]
User[File]
User[Friends]
User[Friends][Account]
User[Friends][File]

Danke für eure Hilfe!

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
   


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


Re: hasMany problem (SOLVED)

2009-06-05 Thread Andreas Derksen

Ok, I did one mistake... Jointables need to be defined in alphabetical 
order... that confused the whole application. so after defining a 
modules_products table instead of the products_modules table i got all 
the data right...

just in case anyone runs into the same problem.

greets
Andreas

Andreas D. schrieb:
 Hello all together,
 i'm currently developing a checklist application. I got problems
 linking the models together right now..

 I got one Checklist model which belongsTo a User, Language,
 OperatingSystem, Product.
 My User hasMany Checklist.

 Now I want to fetch all User related checklists through the
 UsersController. So when I do a $this-User-find('first', array
 ('conditions' = array('id' = $id))); I get only the checklists
 language_id's, operating_system_id's ...
 how do i get the Language.name fields?


 here is the full output:

 Array
 (
 [User] = Array
 (
 [id] = 1
 [name] = Testname
 [email] = testn...@test.de
 [created] = 2009-05-15 12:44:30
 [modified] =
 )

 [Checklist] = Array
 (
 [0] = Array
 (
 [id] = 1
 [user_id] = 1
 [language_id] = 2
 [operating_system_id] = 1
 [product_id] = 1
 [component_string] =
 [created] = 2009-05-15 14:07:16
 [modified] =
 )

 [1] = Array
 (
 [id] = 2
 [user_id] = 1
 [language_id] = 3
 [operating_system_id] = 3
 [product_id] = 4
 [component_string] =
 [created] = 2009-05-15 14:56:33
 [modified] =
 )

 )

 )


 So long,
 Andreas

 
   

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



hasMany problem

2009-06-04 Thread Andreas D.

Hello all together,
i'm currently developing a checklist application. I got problems
linking the models together right now..

I got one Checklist model which belongsTo a User, Language,
OperatingSystem, Product.
My User hasMany Checklist.

Now I want to fetch all User related checklists through the
UsersController. So when I do a $this-User-find('first', array
('conditions' = array('id' = $id))); I get only the checklists
language_id's, operating_system_id's ...
how do i get the Language.name fields?


here is the full output:

Array
(
[User] = Array
(
[id] = 1
[name] = Testname
[email] = testn...@test.de
[created] = 2009-05-15 12:44:30
[modified] =
)

[Checklist] = Array
(
[0] = Array
(
[id] = 1
[user_id] = 1
[language_id] = 2
[operating_system_id] = 1
[product_id] = 1
[component_string] =
[created] = 2009-05-15 14:07:16
[modified] =
)

[1] = Array
(
[id] = 2
[user_id] = 1
[language_id] = 3
[operating_system_id] = 3
[product_id] = 4
[component_string] =
[created] = 2009-05-15 14:56:33
[modified] =
)

)

)


So long,
Andreas

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



Re: hasMany problem

2009-06-04 Thread tobi_one


 I got one Checklist model which belongsTo a User, Language,
 OperatingSystem, Product.
 My User hasMany Checklist.

 Now I want to fetch all User related checklists through the
 UsersController. So when I do a $this-User-find('first', array
 ('conditions' = array('id' = $id))); I get only the checklists
 language_id's, operating_system_id's ...
 how do i get the Language.name fields?


You could increase your recursive level, i.e.

$this-User-recursive=2;

but I would not recommend to do so, as you will get all other
associated models as well and this increases load on the DB.

Alternatively you could write a method in your Location model that
returns your Location.name for a given id, e.g.

function getLocationName($id) {
   return ($this-field('name', array('id' =$id)));
}

and loop through your initial results array. Maybe this isn't the
optimal solution either, if you have to do a lot of loops.
It could be more efficient to just keep on using the id's in the
controller and get the names just in the views (using a helper) - but
this depends on your db and application structure.

Cheers,
tobi_one
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---