Problems with relationships without Auto increment

2015-07-06 Thread Ronaldo Matos Rodrigues
I have the following relationships Contact HABTM List list HABTM Contact Only I had to take my auto_increment primaryKey ID field from the contact table, I'm having problem when using INSERT IGNORE. To replace the auto_incremente created the following trigger: DECLARE AUTOI int UNSIGNED

cakePhp - create drop down list with belongsTo association relationships

2014-07-07 Thread Tze Pin
May i get some examples on create a drop down list with belongsTo relationship? the option that will be show in the drop down list should be retrieve from database table. I hardly can't find any examples on this in the internet. please help. thanks in advance. -- Like Us on FaceBook

Re: cakePhp - create drop down list with belongsTo association relationships

2014-07-07 Thread Stephen S
For example's sake, lets say that you have User and then UserType, user types consists of the following records: Admin, Editor, Contributor, User You want to have a drop down list with all the user types, so when creating a new user you can select which type it should be (in this example), you

Re: Is nested one-to-many table relationships possible in CakePHP?

2013-09-16 Thread John Andersen
The short answer is Yes as CakePHP supports nearly whatever relationships you design in your database. You relationships are as this: Table1 - hasMany - Table2 - hasMany - Table3 With CakePHP you can find data from Table1 alone, from Table1 including Table2, and also from Table1 including

Re: Is nested one-to-many table relationships possible in CakePHP?

2013-09-16 Thread John Andersen
Correction to this part: Suggest you to take a look at the Model and the ModelHelper Contains in the CakePHP book/documentation. Should be: Suggest you to take a look at the Model and the Behaviour Containable in the CakePHP book/documentation. Enjoy, John -- Like Us on FaceBook

Is nested one-to-many table relationships possible in CakePHP?

2013-09-05 Thread Sam
Dear CakePHP experts, While designing a database structure, I created 3 tables. There is a 1-to-many relationship between the first table and second table. There is another 1-to-many relationship between the second table and third table. Does CakePHP allow this kind of table relationship? I

Re: Is nested one-to-many table relationships possible in CakePHP?

2013-09-05 Thread Simon Males
class FirstModel extends AppModel { public $hasOne = array('Second'); public $hasMany = array('Third'); } class SecondModel extend AppModel { public $belongsTo = array('First'); } class ThirdModel extend AppModel { public $belongsTo = array('First'); } On Fri, Sep 6, 2013 at 10:13 AM,

CakePHP - how should I do these relationships and name my tables?

2013-02-26 Thread Don Smith
It's a song and lyrics database. I'm trying to bake an app from my database, which looks like this: (every table does have a primary key 'id', I just left them out..) songs song_name artists artist_name songs_singers artist_id (FOREIGN KEY artists.id)

Re: queries on HABTM relationships

2013-01-03 Thread lowpass
On Wed, Jan 2, 2013 at 8:32 PM, Stefano Campanella leona...@guildofmessengers.com wrote: Yes I am sure. In my case id is not numeric, the permission name is already an identifier for the permission Your DB schema is broken by design, then. Good luck with that. -- Like Us on FaceBook

Re: queries on HABTM relationships

2013-01-03 Thread Stefano Campanella
Broken for CakePHP or broken in general? Generally, I would not see a problem in using a non-numeric primary key, you just have to be conscious of the constraints this imposes. If it is for a constraint of CakePHP, well I didn't experience any problem with that yet. There is no error in

Re: queries on HABTM relationships

2013-01-02 Thread Stefano Campanella
Yes I did, but it does not suit my needs or my organization structure. For me it's at the same time too complicated and too limited. I don't need a tree, I need a graph, where a user can have more than one group; because users can be categorized in more than one way. Anyway, do you have any

Re: queries on HABTM relationships

2013-01-02 Thread lowpass
When running a find('count') the contain param is useless. This is because the main query is fetching a sum, not a set of records from which to fetch the associated 'contain' records. Are you using AuthComponent? You can use that to fetch the User and associated records. However, I can't remember

Re: queries on HABTM relationships

2013-01-02 Thread Stefano Campanella
mmh, ok. But the problem is that even if I change the find(count) into a find(all) it still loads data only from Group table. Yes I am using the AuthComponent for logged in users. But since I want to use my Authorize class also for managing what anonymous users can access I am calling

Re: queries on HABTM relationships

2013-01-02 Thread Ivan Rimac
This simply is solvable with: $this-Auth-userScope = array('User.can_access_admin' = 1); Put that in you beforeFilter function inside AppController, and your problems are solved. If you want to redirect them, than you shoukd do something like this: if ($this-Auth-user()) {

Re: queries on HABTM relationships

2013-01-02 Thread Leonardo
Excuse me Ivan, but there is no reference to userScope attribute anywhere in the source code of cakePHP, I assume you mean $this-Auth-scope. But it still doesn't help me, is was under the impression that that attribute is used to impose conditions for logging users in, this is not my case, I

Re: queries on HABTM relationships

2013-01-02 Thread lowpass
I think that should be something like: $data = $this-controller()-Group-find( 'count', array( 'conditions' = array( 'Group.id' = 1 // hard-coded for testing? ), 'joins' = array( array(

Re: queries on HABTM relationships

2013-01-02 Thread lowpass
I just realised that this also makes no sense. Why are you running a COUNT(*) on Group when your condition is to select only the Group with id = 1? Perhaps you need to start from the beginning and explain what it is you're looking for. And I'll second the suggestion to use ACL. On Wed, Jan 2,

Re: queries on HABTM relationships

2013-01-02 Thread Stefano Campanella
Works like a charm! Thank you so much cricket! Now to reply to your questions: I am using a count because I don't need any content returned. With this query I just check if the record exists, if it does then I know the Group has the specified permission. The count will always return 0 if group 1

Re: queries on HABTM relationships

2013-01-02 Thread Maicon Pinto
array('*id*'='can_access_admin') Do you have sure is ID? Usually ID is numeric. Em terça-feira, 1 de janeiro de 2013 19h23min58s UTC-3, Stefano Campanella escreveu: Hello all, this is my first time posting here. I recently started to study how to use CakePHP and I'm trying to develop

Re: queries on HABTM relationships

2013-01-02 Thread Stefano Campanella
Yes I am sure. In my case id is not numeric, the permission name is already an identifier for the permission On Wednesday, January 2, 2013 3:56:41 PM UTC+1, Maicon Pinto wrote: array('*id*'='can_access_admin') Do you have sure is ID? Usually ID is numeric. Em terça-feira, 1 de

queries on HABTM relationships

2013-01-01 Thread Stefano Campanella
Hello all, this is my first time posting here. I recently started to study how to use CakePHP and I'm trying to develop a website. In my website I am writing a custom authorize component where each user get one or more groups and each group has one or more permissions associated to it. I have

Re: queries on HABTM relationships

2013-01-01 Thread Jeremy Burns | Class Outfit
Have you looked at the inbuilt Auth and ACL components? Might save you a lot of time. Jeremy Burns Class Outfit http://www.classoutfit.com On 1 Jan 2013, at 22:23:58, Stefano Campanella leona...@guildofmessengers.com wrote: Hello all, this is my first time posting here. I recently started

My Model Relationships don't work

2012-11-13 Thread Tsampika
I have three models: Category, Post, Attachment My Relations in these Models are: 1. Category hasMany Post hasMany Attachment 2. Post hasMany Attachment 3. Category hasMany Attachment My attachments table has the following fields: id, title, foreign_key, model The field model contains Category

Re: My Model Relationships don't work

2012-11-13 Thread lowpass
On Tue, Nov 13, 2012 at 10:43 AM, Tsampika bettina.oberrau...@gmail.com wrote: I have three models: Category, Post, Attachment My Relations in these Models are: 1. Category hasMany Post hasMany Attachment 2. Post hasMany Attachment 3. Category hasMany Attachment My attachments table has

CakePHP hasAndBelongsToMany relationships demystified

2012-07-29 Thread Ralf Rottmann
Hi everybody, After days of trial-and-error and almost giving up, I've managed to get some basic and – as I believe – very common scenarios solved in CakePHP. I was wondering, why the documentation is not clear on these aspects, so I described my findings in a somewhat lengthy blog post. You

Conceptual questions regarding HABTM relationships!

2012-07-23 Thread Ralf Rottmann
this but it didn't get updated and no longer works. What is the best way in CakePHP to add additional related objects (not new relationships!) when some already exist? Am I supposed to just manually * save()* records to the join table using the implicit join table model? 4. Question: Last but not least

Two tables with multiple relationships

2012-07-17 Thread Andrew Johnston
Hello Again Everyone- I'm having a bit of trouble establishing my databases. To sum up my application, it allows users to make modules which then can be viewed by other users of the creator's choice. So I have: User hasMany Module -- This is where I place the user id number of the creator

Re: Two tables with multiple relationships

2012-07-17 Thread DiabloGeto
you can very well implement HABTM for users--modules relationship simplly including the owner as a user. Further in the controller or view,give condition for only owner to be able to edit. Or u can give a column as user_id in the module table, to track the owner of the modules, but if u go for

Re: Saving relationships

2012-01-23 Thread jeremyharris
relationships and resaves them. That's the only way it knows not to get duplicates, or that you removed them. The HABTM behavior helps you save/delete single ones without needing to know the others, i.e., saving/removing one follower without knowledge of the other followers. Your follow button should go

Re: Saving relationships

2012-01-23 Thread Sam Sherlock
your relations are in the controller - they should be in the model you don't need to loadModel follower as User hasMany followers - S On 22 January 2012 16:20, J. contact.mysparet...@gmail.com wrote: I'm making a follower system ala Twitter. Here is my UsersController : class

Saving relationships

2012-01-22 Thread J.
I'm making a follower system ala Twitter. Here is my UsersController : class UsersController extends AppController { public $name = 'Users'; public $helpers = array('Html', 'Form', 'Paginator'); var $hasAndBelongsToMany = array( 'Followed' = array( 'className' = 'User',

Altering Relationships on the Fly

2011-12-15 Thread Geoff Douglas
I just learned something and thought I would share. So I came across the need to apply a condition to a hasMany query. I was like how in the world do I do that? // Get all Checkpoints with Appropriate Spec $this-VehicleDailyLog-VehicleDailyLogCheckpoint-VehicleCheckpoint

Queries and Relationships(in DBs)

2011-04-26 Thread goluhaque
If I have a long list of ids(extracted from a table), and I have to pull out corresponding records from another table, can it be done via an iteration loop and stored in a *single* variable(so that it can be easily passed on to the view)? Or do I have to use Relationships? -- Our newest site

Re: Queries and Relationships(in DBs)

2011-04-26 Thread Jeremy Burns | Class Outfit
corresponding records from another table, can it be done via an iteration loop and stored in a single variable(so that it can be easily passed on to the view)? Or do I have to use Relationships? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out

Question about how models using different datasources handle relationships

2011-02-22 Thread Greg Skerman
Hi, I'm curious as to how models which use different datasources handle relationships? If i was to create a datasource to consume a web service, and I wanted it to pick up related fields via a HasOne relationship to a model using a mysql database table, will cake just automagically resolve

Re: Question about how models using different datasources handle relationships

2011-02-22 Thread cricket
On Tue, Feb 22, 2011 at 7:56 AM, Greg Skerman gsker...@gmail.com wrote: Hi, I'm curious as to how models which use different datasources handle relationships? If i was to create a datasource to consume a web service, and I wanted it to pick up related fields via a HasOne relationship

Re: How to setup multiple HABTM relationships between two tables

2011-01-13 Thread Jeremy Burns | Class Outfit
You could consider adding a new column to your joining table that contains a tinyint. By default the value of that field is 0 (which indicates wants) but changes to 1 when he owns it. This assumes that someone can no longer 'want' something when they already 'own' it. Jeremy Burns Class Outfit

Re: How to setup multiple HABTM relationships between two tables

2011-01-13 Thread mklappen
Thanks for replies... I added a two boolean columns to join table for owns and wants Thanks again!! On Jan 13, 3:13 am, Jeremy Burns | Class Outfit jeremybu...@classoutfit.com wrote: You could consider adding a new column to your joining table that contains a tinyint. By default the value of

Re: How to setup multiple HABTM relationships between two tables

2011-01-13 Thread cricket
On Thu, Jan 13, 2011 at 3:55 PM, mklappen mklap...@gmail.com wrote: Thanks for replies... I added a two boolean columns to join table for owns and wants You might be interested in modelizing the join table like this: http://book.cakephp.org/view/1650/hasMany-through-The-Join-Model Also, as

How to setup multiple HABTM relationships between two tables

2011-01-12 Thread mklappen
Hi All I'm having a little difficulty conceptualizing the relationships when setting up a database/models, for a app I'm starting to develop. If I'm creating a basic inventory management application I have the following: Table Name | Columns users | id, user_name, email, etc... items | id, name

Re: How to setup multiple HABTM relationships between two tables

2011-01-12 Thread John Andersen
it into the first. Well, you can think about it. Enjoy, John On 12 Jan., 21:13, mklappen mklap...@gmail.com wrote: Hi All I'm having a little difficulty conceptualizing the relationships when setting up a database/models, for a app I'm starting to develop. If I'm creating a basic inventory management

Re: How to setup multiple HABTM relationships between two tables

2011-01-12 Thread Zaky Katalan-Ezra
If you go with the status columns you need two boolean columns one for own and one for want, its a possible solution. If you want to use two table you can create users_want and users_own. The relation for each table should looks like it would be for items_users. The reason to prefer one

Re: Using USE INDEX or FORCE INDEX in Model-find relationships

2010-12-10 Thread przemoo
it in production environment yet :), but mayby it can help you. -- Przemoo -- View this message in context: http://cakephp.1045679.n5.nabble.com/Using-USE-INDEX-or-FORCE-INDEX-in-Model-find-relationships-tp3281552p3300205.html Sent from the CakePHP mailing list archive at Nabble.com. Check out the new

Re: Using USE INDEX or FORCE INDEX in Model-find relationships

2010-11-29 Thread kadanis
Thanks for the reply. That's give me something to think about. I've not used finderQuery before, I'll certainly give it some time. Thanks again. On Nov 27, 12:20 am, cricket zijn.digi...@gmail.com wrote: On Fri, Nov 26, 2010 at 12:03 PM, kadanis evad.ba...@gmail.com wrote: Just wondering

Using USE INDEX or FORCE INDEX in Model-find relationships

2010-11-26 Thread kadanis
Just wondering if anyone has any suggestions on this. I'm using Cake for a current project and the project lead is insisting we use FORCE INDEX on the queries and table joins. I've searched all over the web and come up empty handed so far and don't particularly want to hand code all the sql

Re: Using USE INDEX or FORCE INDEX in Model-find relationships

2010-11-26 Thread cricket
On Fri, Nov 26, 2010 at 12:03 PM, kadanis evad.ba...@gmail.com wrote: Just wondering if anyone has any suggestions on this. I'm using Cake for a current project and the project lead is insisting we use FORCE INDEX on the queries and table joins. I've searched all over the web and come up

What are the links between relationships and containable?

2010-11-18 Thread Dan
Basically, can containable work without having relationships specified? Or does containable rely on those relationships? In some tutorials, they specify to use recursive = -1 and then containable to get more optimized SQL. I can't help but think, what's the point specifying the relationships

Re: What are the links between relationships and containable?

2010-11-18 Thread Jeremy Burns | Class Outfit
Do you mean relationships in the database or in the models? They are essential in the models (else Cake won't know how to relate models) and although not a Cake requirement I'd say it is paramount from a performance point of view in the database. Jeremy Burns Class Outfit jeremybu

Re: What are the links between relationships and containable?

2010-11-18 Thread Dan
I meant Model relationships. So, they would be required for the containable behavior to work then? On Nov 18, 8:38 am, Jeremy Burns | Class Outfit jeremybu...@classoutfit.com wrote: Do you mean relationships in the database or in the models? They are essential in the models (else Cake won't

Re: What are the links between relationships and containable?

2010-11-18 Thread Jeremy Burns | Class Outfit
to be corrected, but I think recursion is redundant when using contain, so no need to set it to -1 (although I suppose it doesn't hurt). Jeremy Burns Class Outfit jeremybu...@classoutfit.com http://www.classoutfit.com On 18 Nov 2010, at 13:32, Dan wrote: I meant Model relationships. So

Re: What are the links between relationships and containable?

2010-11-18 Thread euromark
when using contain, so no need to set it to -1 (although I suppose it doesn't hurt). Jeremy Burns Class Outfit jeremybu...@classoutfit.comhttp://www.classoutfit.com On 18 Nov 2010, at 13:32, Dan wrote: I meant Model relationships. So, they would be required for the containable

Re: What are the links between relationships and containable?

2010-11-18 Thread Dan
recursion is redundant when using contain, so no need to set it to -1 (although I suppose it doesn't hurt). Jeremy Burns Class Outfit jeremybu...@classoutfit.comhttp://www.classoutfit.com On 18 Nov 2010, at 13:32, Dan wrote: I meant Model relationships. So, they would be required

Re: What are the links between relationships and containable?

2010-11-18 Thread cricket
On Thu, Nov 18, 2010 at 11:03 AM, Dan dannyetdi...@gmail.com wrote: When using contain, I have to specify the $actAs = Containable for it to work, correct? Yes, of course. Just as with any other behavior. If you plan to use it a lot you can put it in AppModel's $actsAs array. And if you have

Re: What are the links between relationships and containable?

2010-11-18 Thread Jeremy Burns | Class Outfit
And don't forget it's $actsAs, not $actAs (cricket has identified this in his response). Jeremy Burns Class Outfit jeremybu...@classoutfit.com http://www.classoutfit.com On 18 Nov 2010, at 17:45, cricket wrote: On Thu, Nov 18, 2010 at 11:03 AM, Dan dannyetdi...@gmail.com wrote: When using

Re: What are the links between relationships and containable?

2010-11-18 Thread cricket
On Thu, Nov 18, 2010 at 1:02 PM, Jeremy Burns | Class Outfit jeremybu...@classoutfit.com wrote: And don't forget it's $actsAs, not $actAs (cricket has identified this in his response). I hadn't noticed. Been bit by that a couple of times (as with not providing the keys in 'fields'). Check out

Re: Question about DB relationships

2010-10-28 Thread dingerkingh
Oh my word - you just made that so easy! Thank you so much for your detailed explanation - it is obvious you put some time into this question for me. Thanks again - I owe you! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You

Re: Question about DB relationships

2010-10-28 Thread dingerkingh
How would one change the label that is generated in this example? 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,

Re: Question about DB relationships

2010-10-28 Thread cricket
On Thu, Oct 28, 2010 at 7:38 PM, dingerkingh dingerki...@hotmail.com wrote: How would one change the label that is generated in this example? label? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message

Question about DB relationships

2010-10-27 Thread dingerkingh
I will try to keep this as simple as possible. I have read through the manual but can't seem to find what I am looking - however, I am sure it is in there somewhere. Here is what I am I am looking to do on a very small scale: names id name tickets id title name_id closed_by What I need to

Re: Question about DB relationships

2010-10-27 Thread cricket
On Wed, Oct 27, 2010 at 7:18 PM, dingerkingh dingerki...@hotmail.com wrote: I will try to keep this as simple as possible.  I have read through the manual but can't seem to find what I am looking - however, I am sure it is in there somewhere. Here is what I am I am looking to do on a very

Re: Dynamic menu based on deep relationships

2010-09-18 Thread meekamoo
honestly can't think of even where I should start here. Building a menu is simple in plain php with simple relationships but it's getting pretty tricky with all the extra levels. Does anyone have any advice on a starting point which I could work with... I'm trying to make it extendable

Dynamic menu based on deep relationships

2010-08-29 Thread Bryan Paddock
around the menu in itself but if he also goes to the a related page (eg suburbs/view/cape-town) then the menu should know where the user is) I honestly can't think of even where I should start here. Building a menu is simple in plain php with simple relationships but it's getting pretty tricky

Re: Dynamic menu based on deep relationships

2010-08-29 Thread Sam
a menu is simple in plain php with simple relationships but it's getting pretty tricky with all the extra levels. Does anyone have any advice on a starting point which I could work with... I'm trying to make it extendable in the sense that I don't want to hard code anything. I'm starting

Relationships

2010-08-24 Thread Philip Thompson
Hi all. Sorry for all these newb questions... trying to learn this stuff. Here's the relationships and tables I have: Relationships: Hardware HABTM Configuration Configuration belongsTo ConfigurationType Tables: configurations - configuration_type_id configurations_hardwares

Re: Relationships

2010-08-24 Thread cricket
On Tue, Aug 24, 2010 at 2:31 PM, Philip Thompson philthath...@gmail.com wrote: Hi all. Sorry for all these newb questions... trying to learn this stuff. Here's the relationships and tables I have: Relationships: Hardware HABTM Configuration Configuration belongsTo ConfigurationType

Re: Relationships

2010-08-24 Thread Philip Thompson
On Aug 24, 2010, at 6:03 PM, cricket wrote: On Tue, Aug 24, 2010 at 2:31 PM, Philip Thompson philthath...@gmail.com wrote: Hi all. Sorry for all these newb questions... trying to learn this stuff. Here's the relationships and tables I have: Relationships: Hardware HABTM Configuration

Re: Using test cases with model relationships throws error

2010-08-06 Thread generaltao
Hi, thanks for getting back to me. I definitely have all my models listed in the fixtures collection. What we just discovered after a lot of testing is that it had to do with $useTable being set to false. For some reason that just throws everything out of whack. If anybody gets this in the

Re: Using test cases with model relationships throws error

2010-08-05 Thread jharris
My best guess, without seeing your test case or fixtures, is that you need to add the fixture to your $fixtures var in your test case. i.e., class MenuItemTestCase extends CakeTestCase { var $fixtures = array('app.menu_item', 'app.alias'); } After doing that, they should load into the test

Using test cases with model relationships throws error

2010-08-04 Thread generaltao
Hi all, Having a strange problem with test cases here. We have two tables in question in this one example - Alias and MenuItem. - Alias belongsTo MenuItem - MenuItem hasMany Alias I am running model test cases on Alias itself. Problem is that if I define the MenuItem hasMany Alias relationship

Re: Relationships with a common table

2010-06-28 Thread Jeremy Burns | Class Outfit
the contact table Now how do I define relationships between the common contact table and each of the remaining ones? I'd love to be able to say practice_site hasone contact, practitioner hasone contact, client hasone contact. Related to my schema design, is there a (generic, reusable) way

Relationships with a common table

2010-06-27 Thread jtomka
, contact_id, qualifications) clients (id, contact_id, emergency_id, guardian_id) // each referencing the contact table Now how do I define relationships between the common contact table and each of the remaining ones? I'd love to be able to say practice_site hasone contact, practitioner hasone contact

Re: Problem with database cascade relationships.

2010-05-31 Thread WebbedIT
You can't specify a condition on a hasMany association as Cake cannot create a join on such an association. In order to get a one to many result set you need to run 2 queries, 1 to find the product and another to find it's many types as such you are getting a logical error thrown back at you.

Re: Problem with database cascade relationships.

2010-05-29 Thread 朝の木
, not just a small piece. Jeremy Burns jeremybu...@me.com On 27 May 2010, at 00:22, 朝の木 wrote: I have three models (with controllers): - Product: Id, Title, Type_id - Type: Id, Description - ProductItem: Id, Product_id, Size, Sold_time Relationships: - Product

Re: Problem with database cascade relationships.

2010-05-27 Thread 朝の木
it all, not just a small piece. Jeremy Burns jeremybu...@me.com On 27 May 2010, at 00:22, 朝の木 wrote: I have three models (with controllers): - Product: Id, Title, Type_id - Type: Id, Description - ProductItem: Id, Product_id, Size, Sold_time Relationships: - Product: belongsTo(Type

Problem with database cascade relationships.

2010-05-26 Thread 朝の木
I have three models (with controllers): - Product: Id, Title, Type_id - Type: Id, Description - ProductItem: Id, Product_id, Size, Sold_time Relationships: - Product: belongsTo(Type), hasMany(ProductItem) - Type: hasMany(Product) - ProductItem: belongsTo(Product) Example: - Product: 1; 'Star

Re: Problem with database cascade relationships.

2010-05-26 Thread Jeremy Burns
, Description - ProductItem: Id, Product_id, Size, Sold_time Relationships: - Product: belongsTo(Type), hasMany(ProductItem) - Type: hasMany(Product) - ProductItem: belongsTo(Product) Example: - Product: 1; 'Star Jeans 502', 4 (...) - Type: 4; 'Trousers' (...) - ProductItem: 7

Re: Question about relationships, extending the blog tutorial

2010-02-25 Thread Andy Dirnberger
controller? No special code is needed in your controller to handle relationships, and you'd only need to add code to your User model (e.g., var $hasMany = array('Post');) if you wanted posts to be retrieved every time you query your user table, which you probably don't

Re: Question about relationships, extending the blog tutorial

2010-02-24 Thread WebbedIT
Can you show us the structure of your table? It seems Cake is not able to find that field. 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.

Re: Question about relationships, extending the blog tutorial

2010-02-24 Thread Andy Dirnberger
code is needed in your controller to handle relationships, and you'd only need to add code to your User model (e.g., var $hasMany = array('Post');) if you wanted posts to be retrieved every time you query your user table, which you probably don't. Once you have it working, 'User

Re: Question about relationships, extending the blog tutorial

2010-02-24 Thread deek
code is needed in your controller to handle relationships, and you'd only need to add code to your User model (e.g., var $hasMany = array('Post');) if you wanted posts to be retrieved every time you query your user table, which you probably don't. Once you have it working, 'User

Re: Question about relationships, extending the blog tutorial

2010-02-23 Thread WebbedIT
^^ What @Andy says is right. Simple rule of thumb for hasMany/hasOne - belongsTo relationships ... whichever model your foreign_key is in, it belongs to the other model. Welcome to CakePHP, it should make learning complex PHP a lot easier for you. I sometimes wish I hadn't taught myself a lot

Re: Question about relationships, extending the blog tutorial

2010-02-23 Thread deek
@Andy says is right. Simple rule of thumb for hasMany/hasOne - belongsTo relationships ... whichever model your foreign_key is in, it belongs to the other model. Welcome to CakePHP, it should make learning complex PHP a lot easier for you.  I sometimes wish I hadn't taught myself a lot of bad

Re: Question about relationships, extending the blog tutorial

2010-02-23 Thread Andy Dirnberger
? No special code is needed in your controller to handle relationships, and you'd only need to add code to your User model (e.g., var $hasMany = array('Post');) if you wanted posts to be retrieved every time you query your user table, which you probably don't. Once you have it working, 'User'] will be added

Re: Question about relationships, extending the blog tutorial

2010-02-23 Thread deek
remove the $belongsTo piece, do your posts show up again? If not, what else did you change? What code do you currently have in your controller? No special code is needed in your controller to handle relationships, and you'd only need to add code to your User model (e.g., var $hasMany = array('Post

Re: Question about relationships, extending the blog tutorial

2010-02-23 Thread deek
controller to handle relationships, and you'd only need to add code to your User model (e.g., var $hasMany = array('Post');) if you wanted posts to be retrieved every time you query your user table, which you probably don't. Once you have it working, 'User'] will be added as an index alongside

Question about relationships, extending the blog tutorial

2010-02-22 Thread deek
First of all let me say I'm very new to CakePHP and complex PHP in general. I based the blog I am working on off the tutorial on the CakePHP website. I skipped creating ACL or a more complex management of permissions because as of now the only people who will be posting content will be Authorized

Re: Question about relationships, extending the blog tutorial

2010-02-22 Thread Andy Dirnberger
Try $belongsTo instead of $hasOne. $belongsTo = array('User'); On Feb 22, 7:03 pm, deek derek.bon...@gmail.com wrote: First of all let me say I'm very new to CakePHP and complex PHP in general.  I based the blog I am working on off the tutorial on the CakePHP website. I skipped creating ACL

Re: How to setup relationships in model User has a Status

2009-12-28 Thread robustsolution
AFAIK, In general we have three statuses for every account created but not active (0) activated (1) banned (-1) It is better to stick to one table (users), so this table have an indexed integer field called status. As for Active, ''Banned, etc... It is just a convention and 9X% of the queries

Complex Relationships

2009-12-02 Thread onlymejosh
Hi, I need some guidance on how to build these model relationships. I need to build something that allows people to book a room in an accommodation. These are the steps. User finds room. User requests to stay in room Owner accepts / declines User Pays / finds another room. I have 3 tables so

Re: Complex Relationships

2009-12-02 Thread John Andersen
relationships. I need to build something that allows people to book a room in an accommodation. These are the steps. User finds room. User requests to stay in room Owner accepts / declines User Pays / finds another room. I have 3 tables so far. Members, Accommodations, BookingRequests

Re: Complex Relationships

2009-12-02 Thread onlymejosh
, Owner, Booking Can one room have more than one Guest per room? Can one booking involve more than one room?    John On Dec 2, 5:42 pm, onlymejosh star...@gmail.com wrote: Hi, I need some guidance on how to build these model relationships. I need to build something that allows people

Re: Complex Relationships

2009-12-02 Thread John Andersen
on how to build these model relationships. I need to build something that allows people to book a room in an accommodation. These are the steps. User finds room. User requests to stay in room Owner accepts / declines User Pays / finds another room. I have 3 tables so far

Re: Question Concerning Nested Relationships

2009-10-22 Thread Bert Van den Brande
. The Post model has other BelongsTo and HABTM relationships to other classes. What I'd like to do is in the Post model retrieve the Media models related to it through the Group model without retrieving any more of the other relationships in the Post model. In other words, I'd like to set recursive=2

Re: Question Concerning Nested Relationships

2009-10-22 Thread Andrew
relationship to a Group model. This Group is related by HABTM to 1+ Media models. The Post model has other BelongsTo and HABTM relationships to other classes. What I'd like to do is in the Post model retrieve the Media models related to it through the Group model without retrieving any

Question Concerning Nested Relationships

2009-10-21 Thread Andrew
I've got a Post model set up that has a BelongsTo relationship to a Group model. This Group is related by HABTM to 1+ Media models. The Post model has other BelongsTo and HABTM relationships to other classes. What I'd like to do is in the Post model retrieve the Media models related

model relationships and retrieve data at runtime

2009-09-17 Thread DierRe
Hi, I have a model with a $belongsTo and a $hasMany relations. My question is: is there a way to decide at RUNTIME when load or not load related model data? I have an index method in my controller where I need only my parent model data and then a view/id method where I need also the related

Re: model relationships and retrieve data at runtime

2009-09-17 Thread brian
Use 'recursive' or 'contain' params in your find() calls. On Thu, Sep 17, 2009 at 8:17 AM, DierRe die...@gmail.com wrote: Hi, I have a model with a $belongsTo and a $hasMany relations. My question is: is there a way to decide at RUNTIME when load or not load related model data? I have an

Re: model relationships and retrieve data at runtime

2009-09-17 Thread DierRe
Ok let me explain my real example so you can understand me better (BTW 'contain' is not in the cookbook I think). I have ParentModel, Child1Model and Child2Model. They're both $hasMany. What can I do to show only Child1Model? Do I use 'contain'? On 17 Set, 18:37, brian bally.z...@gmail.com

Re: model relationships and retrieve data at runtime

2009-09-17 Thread brian
$this-ParentModel-find( 'all', array( 'conditions' = array(...), 'contain' = array('Child1Model') ) ); That will cause Cake to effectively set recursive to -1 BUT grab just the Child1Model data. On Thu, Sep 17, 2009 at 2:55 PM, DierRe

Re: Master Filter for HABTM-Relationships

2009-09-15 Thread Marco
This brought the solution: http://bakery.cakephp.org/articles/view/quick-tip-doing-ad-hoc-joins-in-model-find Marco --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email

  1   2   3   4   >