Google Groups Home
Help | Sign in
Message from discussion Unique rows with auto increment
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Jonathan Wage  
View profile
 More options 16 May, 00:49
From: "Jonathan Wage" <jonw...@gmail.com>
Date: Thu, 15 May 2008 18:49:12 -0500
Local: Fri 16 May 2008 00:49
Subject: Re: [doctrine-user] Unique rows with auto increment

That would work or you could do it with a preSave() record listener
possibly. Read up on listeners and you will probably find what you want.

- Jon

On Thu, May 15, 2008 at 5:22 PM, Matt Hulse <matt.hu...@gmail.com> wrote:

> I have a permissions table which has two fields, page and action.  I
> don't want duplicate permission entries but that's what I'm getting
> since Doctrine wants an auto increment id field.  How do you handle
> this kind of thing?

> I would really like to setup something like a singleton where I create
> a new permission object and when I save, if an entry with the same
> page and action already exists, it returns that entry, otherwise it
> creates a new entry and returns it.

> $permission = new Permission();
> $permission->page = 'accounts';
> $permission->action='create';
> $permission->save(); //permission id = 3

> $permission = new Permission();
> $permission->page = 'accounts';
> $permission->action='delete';
> $permission->save();//permission id = 4

> $permission = new Permission();
> $permission->page = 'accounts';
> $permission->action='create';
> $permission->save();//permission id = 3

> I would like to implement this in a way that will allow me to use
> something like $permission->merge($_POST).  Does this imply overriding
> save?

> I appreciate any suggestions.  Thanks in advance.

> Matt

--
Jonathan Wage
http://www.jwage.com
http://www.centresource.com

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google