Re: Join a table to Itself with a join table
> Well, the supervisor has different behavior (Employee.is_supervisor = > true), so, I'd see it as another entity and model. > But, you can put this condition in the relationship declaration and > use the same model. > True but if I have employee Bob who is a supervisor. Bob supervises Tina, and Pete but Bob also has a supervisor, Sam. In this scenario wouldn't Bob have to exist in both the Employee and Supervisor tables? That would be duplicate data which is bad. Sam (The boss) | Bob (middle manager) / \ Tina Pete (employees) The following link describes a similar scenario, so this what I'm trying to model: http://groups.google.com/group/cake-php/browse_thread/thread/6fea193fdd352916/5997925ec651fe1a?lnk=gst&q=join+to+itself+join+table#5997925ec651fe1a --~--~-~--~~~---~--~~ 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: Join a table to Itself with a join table
> Well, the supervisor has different behavior (Employee.is_supervisor = > true), so, I'd see it as another entity and model. > But, you can put this condition in the relationship declaration and > use the same model. > True but if I have employee Bob who is a supervisor. Bob supervises Tina, and Pete but Bob also has a supervisor, Sam. In this scenario wouldn't Bob have to exist in both the Employee and Supervisor tables? That would be duplicate data which is bad. Sam (The boss) | Bob (middle manager) / \ Tina Pete (employees) The following link describes a similar scenario, so this what I'm trying to model: http://groups.google.com/group/cake-php/browse_thread/thread/6fea193fdd352916/5997925ec651fe1a?lnk=gst&q=join+to+itself+join+table#5997925ec651fe1a --~--~-~--~~~---~--~~ 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: Join a table to Itself with a join table
> Well, the supervisor has different behavior (Employee.is_supervisor = > true), so, I'd see it as another entity and model. > But, you can put this condition in the relationship declaration and > use the same model. > True but if I have employee Bob who is a supervisor. Bob supervises Tina, and Pete but Bob also has a supervisor, Sam. In this scenario wouldn't Bob have to exist in both the Employee and Supervisor tables? That would be duplicate data which is bad. Sam (The boss) | Bob (middle manager) / \ Tina Pete (employees) The following link describes a similar scenario, so this what I'm trying to model: http://groups.google.com/group/cake-php/browse_thread/thread/6fea193fdd352916/5997925ec651fe1a?lnk=gst&q=join+to+itself+join+table#5997925ec651fe1a --~--~-~--~~~---~--~~ 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: Join a table to Itself with a join table
Hi, Thanks for the response. I want to avoid adding a Supervisor model as a supervisor is just another employee. The EmployeesSupervisor.supervisor_id is a foreign key to Employees.id. I did initial try to set this up as HABTM but after reading other post that suggested otherwise I switched to the current method. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Join a table to Itself with a join table
Hi All, I've been reading other posts on this but I still can seem to make it work. This post seems to be what I want to do but I'm still having trouble. http://groups.google.com/group/cake-php/browse_thread/thread/6fea193fdd352916/5997925ec651fe1a?lnk=gst&q=join+to+itself+join+table#5997925ec651fe1a I have a employees table: CREATE TABLE employees ( id integer NOT NULL, user_id integer, start_date date, termination_date date, vacation_rate numeric(15,2), is_supervisor boolean, full_time boolean, cont boolean, part_time boolean, part_time_amount numeric(15,2), on_leave boolean, birthday date ); And join table employees_supervisors: CREATE TABLE employees_supervisors ( id integer NOT NULL, employee_id integer, supervisor_id integer ); The relationship is that an employee can have multiple supervisors and a supervisor can supervise many employees. I read that the HABTM is maybe not the best option, so I tried to make hasMany and belongsTo releationships: In Employee Model: var $hasMany = array( 'Supervisors'=>array('className'=>'Employee', 'foreignKey'=>'employee_id', 'conditions' => '', 'fields' => '', 'order' => '' ) ); var $belongsTo = array( 'User' => array('className' => 'User', 'foreignKey' => 'user_id', 'conditions' => '', 'fields' => '', 'order' => '' ), 'Supervisor'=>array('className'=>'EmployeesSupervisor', 'foreignKey' => 'id', 'conditions' => array('Employee.is_supervisor'=>true), 'fields' => '', 'order' => '' ) ); In EmployeesSupervisor model: var $hasMany = array( 'Employees' => array('className' => 'EmployeesSupervisor', 'foreignKey' => 'employee_id', 'conditions' => '', 'fields' => '', 'order' => '' ) ); var $belongsTo = array( 'Supervisor' => array('className' => 'Employee', 'foreignKey' => 'id', 'conditions' => '', 'fields' => '', 'order' => '' ) ); My problem right now is that when the joins occur it joins "Employee"."id" = "Supervisor"."id" when what I want is "Employee"."id" = "Supervisor"."employee_id" and/or "Employee"."id" = "Supervisor"."supervisor_id". I tried the associationForeignKey but I think that only works with HABTM relationships. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Custom Auth Login Problem
Hi, I've created an Ldap component that connects to an Active directory server to do authentication. The ldap componet works well and I'm using it for a number of applications. I created a custom authentication component (MyAuth) that overrides the isAuthorized and hashPasswords function. MyAuth also contains a login function. This function checks with the database to see if a user should be authenticated via the password in the database or the active directory. My app_controller looks like so: function beforeFilter() { if (isset($this->Auth)) { $this->Auth->userScope = array('User.active' => 'True'); $this->Auth->fields = array('username' => 'username', 'password' => 'password'); $this->Auth->loginAction = '/users/login'; $this->Auth->logoutRedirect = '/users/index'; $this->Auth->authError = 'You are not authorized to access that location.'; $this->Auth->autoRedirect = false; $this->Auth->authorize = 'object'; $this->Auth->object = $this->MyAuth; $this->Auth->authenticate = $this->MyAuth; $this->Auth->loginRedirect = $this->Session- >read('Auth.from'); //$this->Auth->allow('*'); // for testing only } } My Users/login function looks like this: function login() { $user_id = $this->Auth->user('id'); if (!empty($user_id) && $this->Session->valid()) { $this->redirect('/users/index'); } if (!empty($this->data)) { if (!$this->MyAuth->login($this->data)) { $this->set('error_code', -2); } else { $this->redirect('/users/index'); } } } The problem is that Auth->startup is called before $this->MyAuth- >login(). The Auth startup automatically tries to do Auth->login if there is a username and password. In most cases this is fine except when I have a user with a password in the database and that user is also set to authenticate via the active directory. Is there anyway I can force cake to use my authentication only? --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Error updating an ACO in Cake1.2 beta using a postgres DB
Thanks! I'll make the changes in my code. --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Error updating an ACO in Cake1.2 beta using a postgres DB
When I try to update an ACO I get the following error: LINE 1: UPDATE "acos" SET "Aco"."lft" = "Aco"."lft" + 2 WHERE "id" ... ^ [CORE/cake/libs/model/ datasources/dbo/dbo_postgres.php, line 122] Some where along the way an alias is being added to the SQL for the ACO table. So far problem is only occurring when I try to update the ACO table. When I update any of the tables that I created, the update works fine. I grabbed the latest code from the datasouces directory in SVN today but it didn't seem to help. I'm not sure where to start looking for this problem. Any ideas? I made a quick hack to dbo_souce.php in _prepareUpdateFields() to stip out the alias. This of course is the wrong place but I need to get this working ASAP. thanks. --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: sessions being dropped on redirect or whenever i call a new page
I found the problem with my code using 1.2 beta. There was a destroy('Menu'); method that was called. The intent was to only delete part of the session that referred to the menu. I replaced this with delete('Menu'); and it works. I have no idea how this working in 1.2 pre beta but it did... --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: sessions being dropped on redirect or whenever i call a new page
Has anyone else had this problem? Or more importantly, has anyone solved this problem? --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: othAuth looses session - upgrading to new 1.2.0.6311 (2008)
My session data is being lost also. Does anyone have a solution yet? My core.php is set as follows: Configure::write('Session.save', 'database'); Configure::write('Session.table', 'cake_sessions'); Configure::write('Session.database', 'default'); Configure::write('Session.cookie', 'CAKEPHP'); Configure::write('Session.timeout', '120'); Configure::write('Session.start', true); Configure::write('Session.checkAgent', true); The only place session_start is invoked is in ./cake/libs/session.php on lines 554, 621, and 627. --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Best practices for organizing tables?
Thanks for the offer. I'd prefer to just have a few examples of best practices though. We will be making heavy use of plugins and we just wanted an example of way to organize the tables. --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Best practices for organizing tables?
I think I'll use prefixes. I forgot about the $useTable variable. I remember reading about it now that you mention it. thanks for the reply. --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Best practices for organizing tables?
What are the best practices for organizing tables? My scenario is that I want to have a number of common tables and then create a number of modules (plugins) that share the common tables. I would like to keep the plugin tables organized in some way. For example I have the following common tables: users groups login_history I have the following plugin tables: quizzes questions answers questions_users (HABTM) I want to be able to organize questions and answers. I could do this using a prefix like quiz_questions. The problem with this method is that it makes for long ugly table/controller/model names especially for HATBM relationships. And I don't think the bake scripts in 1.2 handle the relationships properly. I'm using postgres so I thought schemas would be a better way to go. There is a patch here https://trac.cakephp.org/ticket/1623 to allow for multiple schemas and it seems to work. The problem is this may restrict what databases I can run on and all it does is add the schema to a search path. If two or more schemas contain the same tablename, I'm not sure this implementation works. --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: ACL Aro multiple parents Cake 1.2
I'm just taking a stab in the dark here but is the following possible? Hopefully someone can help me out.. Create three tables: create table users( id, firstname, lastname, username, email ); create table groups( id, name, description, parent_id); create table groups_users( id, users_id, groups_id, default ); --default is a boolean Now if we have the user "user1" with an id of 1 and groups "group1" and "group2", is there anyway you can have alias' such as "group1_user1" and "group2_user1"? These alias' would have an ID of 1 the same as "user1". $aro->create( 1, null, 'user1' ); $aro->create( 0, null, 'group1' ); $aro->create( 0, null, 'group2' ); $aro->setParent('group1', 'group1_user1'); $aro->setParent('group2', 'group2_user1'); I'm just learning this but can you not look up the permissions based on the alias or the id. Some extra logic is needed in the users_controller.php (or somewhere else?) to handle this. The extra logic would need to look up the default group's permission first and then the remaining group permissions if the default group is denied. Now as I'm reviewing this post I'm wondering how the $aro- >setParent('group1', 'group1_user1'); knows that "group1_user1" is actually user1? Do I have to do something like this: $aro->create( 1, null, 'user1' ); $aro->create( 1, null, 'group1_user1' ); $aro->create( 1, null, 'group2_user1' ); This looks clunky. --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: ACL Aro multiple parents Cake 1.2
I'd love to see an example of this also. I've been combing the web trying to find a good example. --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Cake 1.2 Console constants
Hi, I'm creating some templates for views and controllers using cake1.2.0.5427. I want to to have order columns so that if I use a certain column name the controller will generate a changeOrder function. For example assume the following table menu_items: table menu_items( id, itemname, itemlink,sortorder ) If I detect the sortorder column name I want up and down arrows to be displayed so that I can easily re-order the menu items. All of the view templates are in basically place but I'm working on a vendors/shells/tasks/controller.php. I've defined $orderColumns = array('sortorder'); in app/config/ core.php. My problem is this: I want to define a constant $orderColumns that can be referenced when I call 'console/cake bake'. Where do I define $orderColumns? $orderColumns is available in console/cake.php but the not in shells/ tasks/controller.php or shells/templates/views/index.ctp when I'm trying to bake a controller or view. --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: how to develope project using cake php
I found these tutorials very helpful. If you follow them through it will give you a start. http://www.scribd.com/search?sortorder=views&query=tags%3Acakephp On Sep 7, 4:05 am, vills <[EMAIL PROTECTED]> wrote: > see i m totally new to cakephp and i need to develope my project using > cakephp framework .Previously all projects was done using simple php > coding no framework nothing was used.Can any body tell me how do i > start my application using cakephp. Before this i used devlope coding > in php and transfer it on ftp and application will run .I have read > the begining mannual but not understood how to start.So plz tell me > from the beging steps.If posiible plz give any example of the > application where cakephp was used. > Will be very thankfull if somebosy helps me in > this regards --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---