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

Re: queries on HABTM relationships

2013-01-03 Thread lowpass
On Wed, Jan 2, 2013 at 8:32 PM, Stefano Campanella 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 https://www.facebook.com/CakePHP Find

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

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 dev

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

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

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,

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()) { if(isset(

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

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

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 wrote: > Hello all, > this is my first time posting here. I recently started to study how to use > CakePH

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 pr