I have a project and I am trying to figure out the best way to associate my
models and how to structure them. In particular, I have something like a
polymorphic association situation.
I want to have a table of transactions, that list the transfers of money
from one user to another. The
In exactly the same way :-)
You join table (products_sizes) would hold the stock field
id (PK)
product_id (FK)
size_id (FK)
stock (INT)
On Sep 17, 9:27 pm, VitillO [EMAIL PROTECTED] wrote:
Hi, i have the following structure for a tshirt online store:
Product HABTM Size
Size HABTM Product
Hi, i have the following structure for a tshirt online store:
Product HABTM Size
Size HABTM Product
Association table:
products_sizes
The problem is, i need a stocks system.
For example, say i have 50 pieces of S (size) for a particular tshirt,
before using cake i had a column 'stock' in the
OK, so I've got two tables: tasks and priorities. Many tasks can share
the same priority. So is this a HABTM relationship?
With HABTM, you usually have a join table but in my situation I don't
need one. I just have a foreign key in my tasks table (priority_id)
which points to the index of the
I always remember it like this:
If a table contains a foreign key, it's like a little label that
another object has put on it... i.e. it belongsTo something else.
hth/fwiw,
John
On Jul 3, 2008, at 1:38 PM, Jonathan Snook wrote:
A priority hasMany tasks.
A task belongsTo a priority.
@Jonathan, yes it always a bit confusing the hasOne (in Cake)..
because a Task hasOne priority, no matter if this priority is
shared .. but for cake it'a a belongsTo .. :-) Even after using for
few months (years)... hasOne always make me think twice (actually I
use it very rarely)..
On Jul 3,
Don't use HABTM, make a full model for the table, then change the
associations to hasMany/belongsTo.
HTH,
- Dardo Sordi.
On Fri, Feb 15, 2008 at 12:26 AM, Snadly [EMAIL PROTECTED] wrote:
For this question, lets assume I have 3 models: A, B, and C.
I have a HABTM relationship setup
Brilliant! This actually worked out much better for me.
Thanks
Brad
On Feb 15, 4:01 am, Dardo Sordi Bogado [EMAIL PROTECTED] wrote:
Don't use HABTM, make a full model for the table, then change the
associations to hasMany/belongsTo.
HTH,
- Dardo Sordi.
On Fri, Feb 15, 2008 at 12:26 AM,
For this question, lets assume I have 3 models: A, B, and C.
I have a HABTM relationship setup between two models, A and B.
The many to many table looks like this:
id,
a.id,
b.id,
c.id --- This can be NULL or it can be a record out of model C.
What I want to do is to have the Model C record
Is this proper behavior? It seems like it should not return an Answer
array at all.
Yes. You can do something like
if(isset($question['Answer']['id']))
{
/* do something with answer */
}
You might consider reversing it and putting the foriegn key in the
questions table, and having each
Thanks for the reply Brian.
Interesting thought on reversing the association, that would work
pretty well me thinks, but it doesn't follow the program logic.
Shouldn't something like this work...
$unansweredQuestions = $this-Question-findAll(array('Answer.id' =
''));
It just doesn't.
On Jan
Oh wait, I just figured it out.
$unansweredQuestions = $this-Question-findAll(array('Answer.id' =
null));
Had no idea I could just put null in there. Sweet, thanks.
On Jan 27, 12:10 am, Corie [EMAIL PROTECTED] wrote:
Thanks for the reply Brian.
Interesting thought on reversing the
Using Cake 1.2, when I perform a findAll() on a model with a hasOne
association it's returning an array for the associated table even if
there is no record.
Here's an example.
// question.php
class Question extends AppModel
{
var $name = 'Question';
var $hasOne = 'Answer';
}
//
In their basic form, models in Cake are a way of accessing SQL-data.
They may also contain any number of other data-manipulation
functionality that may be relevant. They do not represent the data in
the same direct way you are used to. They represent a way of accessing
and manipulating the data.
Appreciate the clarification, points me in the right direction.
Thanks.
On Jan 16, 8:58 pm, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
In their basic form, models in Cake are a way of accessing SQL-data.
They may also contain any number of other data-manipulation
functionality that may be
I am just trying to get some clarity on associations. I've done a
little object orientated programming before and in cake it seems a
little different in regard to extending objects. In my case I have a
table for people, clients and suppliers. Obviously people contains
basic info like name,
This does not look like a typical association, I don't think this kind
of relationship can be managed with a simple association.
I think you will need to use an appropriate function within the Item
Model with the business logic that manages the swap.
On Jun 28, 5:35 am, Alteczen [EMAIL
On Jun 14, 2006, at 12:01 PM, Garth Braithwaite wrote:
I have a users table with a list of users and info about each, one
record is usertype_id which is a foreign key that relates to the
usertypes table that contains id, and title, which is just a
description of the type of user it is.
I
I have a users table with a list of users and info about each, one
record is usertype_id which is a foreign key that relates to the
usertypes table that contains id, and title, which is just a
description of the type of user it is.
I tried a few associations, but I am having some troubles. I
I think this is an easy association question but Cake is not behaving
like I expect.
In my app, users complete a form called an Epp. Included on the form
are a bunch of repititive input fields where the users key in text
about their current courses.
Example:
Question: List the courses you
PS - If I have to name the fields in `courses` uniquely, that's fine.
That would be, I think, an even more basic hasMany association. I
can't get that to work, either.
That would look more like:
CREATE TABLE `courses` (
`id` int(10) unsigned NOT NULL auto_increment,
`epp_id` int(10) NOT
21 matches
Mail list logo