Re: UUID or INT and association problems

2011-01-19 Thread euromark
you might want to consider using char(36) instead


On 19 Jan., 14:43, jjw  wrote:
> If I'm using the uuid as the id field, then I do something like this:
> parents
>     id                varchar(36)
>     other fields
>
> children
>     id                varchar(36)
>     parent_id     varchar(36)
>
> Basically all that is different in the DB is the id field is a varchar
> rather then INT
>
> However, generally I am using int fields for the id, and create a
> second field for uuid only on tables that need to be synced between
> other servers and clients.
>
> parents
>     id               int
>     uuid           varchar(36)
>     other fields
>
> children
>     id               int
>     uuid           varchar(36)
>     parent_id    int
>
> On Jan 18, 4:17 am, Pehmolelu  wrote:
>
>
>
>
>
>
>
> > Im defining a completely new database. I have now faced a problem
> > which I would describe as "usual" but still could not find good
> > information from web. So here's the problem:
>
> > I have many guide tables in database such as:
> > Skills
> > Places
> > Activities
> > and so on...
>
> > Now to all these guide types I'd like to add a comment feature and
> > other similar features. I have many guide types so I dropped the idea
> > of having separate comment table for each of them. I need one comment
> > table.
>
> > The question is, what is the best way to achieve this?
>
> > I understand what UUIDs are but I dont understand how they actually
> > work in database with Cakephp or how they are even used.
>
> > Here's how I thought it works but dont know if its right way and is it
> > how UUIDs are used (or if it is right at all):
>
> > Create a new table: Guides which could have UUID field
> > Then link all those guide types to (Guide as parent and the other as
> > child)
> > Parent and Child have both UUID fields and when creating a guide
> > Parent and Child gets same UUID so they can be linked.
> > Then link comments to Guides by using UUID field that points to Guide
> > plus seperate id int field for comments..
>
> > Please tell me if this is correct way or is it total garbage and if
> > so, how I should do it?

-- 
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: UUID or INT and association problems

2011-01-19 Thread jjw

If I'm using the uuid as the id field, then I do something like this:
parents
idvarchar(36)
other fields

children
idvarchar(36)
parent_id varchar(36)

Basically all that is different in the DB is the id field is a varchar
rather then INT

However, generally I am using int fields for the id, and create a
second field for uuid only on tables that need to be synced between
other servers and clients.

parents
id   int
uuid   varchar(36)
other fields

children
id   int
uuid   varchar(36)
parent_idint


On Jan 18, 4:17 am, Pehmolelu  wrote:
> Im defining a completely new database. I have now faced a problem
> which I would describe as "usual" but still could not find good
> information from web. So here's the problem:
>
> I have many guide tables in database such as:
> Skills
> Places
> Activities
> and so on...
>
> Now to all these guide types I'd like to add a comment feature and
> other similar features. I have many guide types so I dropped the idea
> of having separate comment table for each of them. I need one comment
> table.
>
> The question is, what is the best way to achieve this?
>
> I understand what UUIDs are but I dont understand how they actually
> work in database with Cakephp or how they are even used.
>
> Here's how I thought it works but dont know if its right way and is it
> how UUIDs are used (or if it is right at all):
>
> Create a new table: Guides which could have UUID field
> Then link all those guide types to (Guide as parent and the other as
> child)
> Parent and Child have both UUID fields and when creating a guide
> Parent and Child gets same UUID so they can be linked.
> Then link comments to Guides by using UUID field that points to Guide
> plus seperate id int field for comments..
>
> Please tell me if this is correct way or is it total garbage and if
> so, how I should do it?

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


UUID or INT and association problems

2011-01-18 Thread Pehmolelu
Im defining a completely new database. I have now faced a problem
which I would describe as "usual" but still could not find good
information from web. So here's the problem:

I have many guide tables in database such as:
Skills
Places
Activities
and so on...

Now to all these guide types I'd like to add a comment feature and
other similar features. I have many guide types so I dropped the idea
of having separate comment table for each of them. I need one comment
table.

The question is, what is the best way to achieve this?

I understand what UUIDs are but I dont understand how they actually
work in database with Cakephp or how they are even used.

Here's how I thought it works but dont know if its right way and is it
how UUIDs are used (or if it is right at all):

Create a new table: Guides which could have UUID field
Then link all those guide types to (Guide as parent and the other as
child)
Parent and Child have both UUID fields and when creating a guide
Parent and Child gets same UUID so they can be linked.
Then link comments to Guides by using UUID field that points to Guide
plus seperate id int field for comments..

Please tell me if this is correct way or is it total garbage and if
so, how I should do it?

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: Association problems

2009-06-21 Thread Miles J

Yeah simple stuff like that is annoying. Also be sure to remove your
tmp/cache/models
--~--~-~--~~~---~--~~
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: Association problems

2009-06-21 Thread David

My "G" in Game.php is capitalized...  I really feel like an
idiot.  I just saw in the docs that it has to be lowercase; It's now
working perfectly.  Shouldn't it throw a warning or something when
something like this happens?  Well anyways, thanks for all the help,
David.

On Jun 21, 10:01 pm, David  wrote:
> My find query is $this->Game->find('all'), but I think I've figured
> out the problem.  I don't think that cakePHP is finding my game model,
> Game.php.  I deleted everything inside the class and nothing
> happened.  I even replaced it with gibberish to see if it would throw
> error but still nothing happened.  Why wouldn't it locate this file?
> Game.php resides in app/models.  Does this sound right to you?
>
> On Jun 21, 9:48 pm, Miles J  wrote:
>
> > Are you using recursive or contain?
>
> > Whats your find query.
--~--~-~--~~~---~--~~
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: Association problems

2009-06-21 Thread David

My find query is $this->Game->find('all'), but I think I've figured
out the problem.  I don't think that cakePHP is finding my game model,
Game.php.  I deleted everything inside the class and nothing
happened.  I even replaced it with gibberish to see if it would throw
error but still nothing happened.  Why wouldn't it locate this file?
Game.php resides in app/models.  Does this sound right to you?

On Jun 21, 9:48 pm, Miles J  wrote:
> Are you using recursive or contain?
>
> Whats your find query.
--~--~-~--~~~---~--~~
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: Association problems

2009-06-21 Thread Miles J

Are you using recursive or contain?

Whats your find query.
--~--~-~--~~~---~--~~
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: Association problems

2009-06-21 Thread David

Ok I was looking through the docs and found the bindModel funcion.
When I add $this->Game->bindModel(array('belongsTo'=>array
('Genre'=>array('className'=>'Genre'; to my controller it
successfully associates the models.  Why is cakePHP not doing this
implicitly?
--~--~-~--~~~---~--~~
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: Association problems

2009-06-21 Thread David

Array
(
[0] => Array
(
[Game] => Array
(
[id] => 1
[user_id] => 1
[genre_id] => 1
[name] => Ball Surfer
[width] => 500
[height] => 500
[short_description] => Keep your kitten afloat!
[description] => Help your cat learn to surf, but
without it ever getting wet! Use the arrow keys to balance your
character and try for the highest score!
[approved] => 1
[views] => 0
[average] => 0
[votes] => 0
[created] => 2009-06-19 12:43:46
[modified] => 2009-06-19 12:43:50
)

)

)

On Jun 21, 9:08 pm, Miles J  wrote:
> What appears when you put debug($products) in your view?
--~--~-~--~~~---~--~~
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: Association problems

2009-06-21 Thread Miles J

What appears when you put debug($products) in your view?
--~--~-~--~~~---~--~~
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: Association problems

2009-06-21 Thread David

That still isn't working :/

On Jun 21, 7:27 pm, iFeghali  wrote:
> you also have to set $recursive = 1 in the model.
>
> On Jun 21, 9:21 pm, David  wrote:
>
> > I've tried using both hasOne and belongsTo and neither works.  I was
> > initially using belongsTo but that didn't work so I switched to
> > hasOne.  I just tried it again to be sure, and it still isn't
> > working.  Do I need to set up foreign keys within mysql?
--~--~-~--~~~---~--~~
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: Association problems

2009-06-21 Thread David

I've tried using both hasOne and belongsTo and neither works.  I was
initially using belongsTo but that didn't work so I switched to
hasOne.  I just tried it again to be sure, and it still isn't
working.  Do I need to set up foreign keys within mysql?
--~--~-~--~~~---~--~~
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: Association problems

2009-06-21 Thread iFeghali

you also have to set $recursive = 1 in the model.

On Jun 21, 9:21 pm, David  wrote:
> I've tried using both hasOne and belongsTo and neither works.  I was
> initially using belongsTo but that didn't work so I switched to
> hasOne.  I just tried it again to be sure, and it still isn't
> working.  Do I need to set up foreign keys within mysql?
--~--~-~--~~~---~--~~
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: Association problems

2009-06-21 Thread Miles J

As marcelo said, it would be a belongsTo, not a hasOne.

If the genre_id is in the games table, then its belongsTo. If the
game_id is in the genre table, its a has 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
-~--~~~~--~~--~--~---



Re: Association problems

2009-06-21 Thread Marcelo Andrade

On Sun, Jun 21, 2009 at 3:05 PM, David wrote:
>
> I'm new to cakePHP and I don't know why my associations aren't
> working.  I'm trying to associate a game with a genre.  Each game has
> a genre_id column
> (..)
>  class Game extends AppModel {
>        var $name = 'Game';
>        var $hasOne = 'Genre';
> }

Your models are not correct.  If Game has a genre_id
column, in a CakePHP association you said that Game
belongsTo Genre, so Genre hasOne (or hasMany,
depending of your case) Game.

http://book.cakephp.org/view/81/belongsTo

Best regards.

--
MARCELO DE F. ANDRADE
Belem, PA, Amazonia, Brazil
Linux User #221105

http://mfandrade.wordpress.com

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



Association problems

2009-06-21 Thread David

Hello,

I'm new to cakePHP and I don't know why my associations aren't
working.  I'm trying to associate a game with a genre.  Each game has
a genre_id column which corresponds to a genre in a table named
genres.

My game model looks like this:



Genre model:



Games controller:

set('game', $this->Game->find());
}
}
?>


Now in my games view when I call I try to access $game['Genre'] I get
an undefined index error.  Is there something I'm missing here?

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



Custom Model Association Problems

2008-06-16 Thread benjam

I have the following tables with the following fields

territories
-
id
zip_start
zip_end


offices
-
id
zipcode


and I want to associate via hasMany and belongsTo on the following
conditions
(territories hasMany offices) and (offices belongsTo territories):

offices.zipcode BETWEEN territories.zip_start AND territories.zip_end


How can I do this in Cake?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: association problems/sql help

2006-07-09 Thread Jon Bennett

> I'm running into a few issues with 2 HABTM associations. I'm working
> on a events listing app (bit like upcoming.org but more specific) and
> I have a tagging system in place. I have the following tables:
>
> events
> tags
> events_tags
>
> I want to be able to list events by date, and also only show events
> that come after the current date, basiucally doing:
>
> Event.event_start > now()
>

no worries, got it sorted:

'SELECT Tag.id, Tag.name, Tag.handle, Tag.description, Tag.tag_count,
Tag.created, Tag.modified, Event.event_start FROM events AS Event,
tags AS Tag JOIN events_tags ON events_tags.event_id = {$__cakeID__$}
AND events_tags.tag_id = Tag.id WHERE Event.event_start > now()'

think I'm starting to realise my SQL needs some work ;)

jb

-- 


jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



association problems/sql help

2006-07-09 Thread Jon Bennett

hi,

I'm running into a few issues with 2 HABTM associations. I'm working
on a events listing app (bit like upcoming.org but more specific) and
I have a tagging system in place. I have the following tables:

events
tags
events_tags

I want to be able to list events by date, and also only show events
that come after the current date, basiucally doing:

Event.event_start > now()

but no matter what I try I can't get Cake to do it.

Originally I tried:

var $hasAndBelongsToMany = array(
'Event' =>
array(  'className' => 'Event',
'joinTable' => 
'events_tags',
'foreignKey'=> 'tag_id',
'associationForeignKey' => 'event_id',
'conditions'=> 'Event.event_start > 
now()',
'order' => '',
'uniq'  => true,
'finderSql' => '',
'deleteSql' => '',
'insertSql' => '',
)

But I get an SQL error because Cake isn't querying the Events table,
so Event.event_start isn't available. I then tried manually entering
the sql using finderQuery like so:

'SELECT Tag.id, Tag.name, Tag.handle, Tag.description, Tag.tag_count,
Tag.created, Tag.modified FROM tags,events AS Tag,Event JOIN
events_tags ON events_tags.event_id = {$__cakeID__$} AND
events_tags.tag_id = Tag.id WHERE events.event_start > now()'

I think it's basically a lack of SQL knowledge that's letting me down,
but I'm not sure how to go about it, what I'm trying to write is:

'select all events with the tag_id of 'nn' that have an event_start
date after the current time' (I think!)

Any help from anyone hugely appreciated!

thanks,

jon

-- 

jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---