Dealing with big cakephp applications

2013-07-29 Thread Diogo FC Patrao
Hello

In my company, we develop software with cakephp for internal usage. The 
software is getting big for managing it as a single project (46 
controllers, 94 models), and we've been thinking about splitting it in two 
or three different software, each to manage one different domain of the big 
picture (like, a system for user and permission management, other for 
projects, other for financing).

However, there is the need for those modules keep comunicating. For 
instance, a report will need to get for all projects belonging to user X 
the current balance - That would need at least three models in three 
different modules. If I would be working with three different and 
independent cakephp, either I need to (1) get a copy of models from the 
other software, or (2) communicate via webservices.

(1) is faster, however, I'll have a huge number of models anyway. Not to 
mention, as business rules are in the models, when one is updated, it must 
be copied to the other systems, causing a maintenance nightmare.

(2) is ideal as it really encapsulate responsabilities, however it is slow. 
For instance, if I make a find on model Projects, each having a list of 
people linked to it, I'd like to bind those models. As far as I know, 
there's no Webservice Datasource, so I'll need to do it by hand.

I'd rather (3) have everything deployed in one big cakephp installation, 
but maintain my repositories apart; however it would difficult testing. But 
I guess that, when working with big problems like that, you really have to 
face some difficulties.

What are your thoughts on that problem?

Thanks!

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Custom model association column

2012-02-21 Thread Diogo FC Patrao
Hi all

I have a data model like this:

*HospitalAdmission* belongsTo *Subject* hasMany *Contents*

That is, I have a subject_id column on HospitalAdmission, and a column with
the same name in Contents. Plus, HospitalAdmission is in one database, and
Subject and Contents in other, not being possible (for technical reasons)
to join them together in the same query.

I'd like to directly get all HospitalAdmissions linked to some Content, but
I only found documentation on how to specify the foreignKey of a hasMany
relation - in this case, I would have to specify hasMany not to look into
Content.id field.

I could do this programatically (by getting all subject_id from a
Content-find('all') and then HospitalAdmission-find('all')), or putting
the full relationship with Subject (which would be a little cumbersome, as
I don`t really need any information in this

any thoughts?

--
diogo patrão

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


Form from another model in a view

2011-11-14 Thread Diogo
So I'm trying to extend the Blog tutorial adding some comments:

Post hasMany Comments

I want to display the add comment form in the same view as the 'post
view'. Thing is I don't know the best way to get this approach. I
thought about three ways:

Creating a function in Comments Controller to handle the data.
Creating a function in Post Controller to handle the data.
Deal with the data in the same function that deals with the post
views.
The main problem with the two first 'solutions' is that the validation
errors doesn't show up in the form unless I do some messy hacking of
saving the invalidated field in a session variable and then parsing
the variable on the beforeFilter callback, like this:

function beforeFilter () {
if ($this-Session-check('comment_error')) {
$this-Post-Comment-validationErrors = $this-Session-
read('comment_error');
$this-Session-delete('comment_error');
}
}

What I basically do is adapt the invalidated fields to the actual view
and allow it to show properly. This works really well, but it seems so
ugly to me. What would be the best approach?

Another related question: should a controller reflect a view? I mean
on that example, I thought about only having a Comment Model and
dealing with all the data in the controller where's the form to add a
comment (even though it's in the Post Controller).

-- 
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: Form from another model in a view

2011-11-14 Thread Diogo
That's exactly my line of thinking. I might use a comments controller
if it's being used on more than one model. Other than that, I think
it's not worth all the work. Thanks!

On Nov 14, 2:32 pm, phpMagpie p...@webbedit.co.uk wrote:
 I don't think there is a right and wrong way to be honest, I have done this
 in the Comment controller and in my BlogPost controller, if comments are
 used across many models then probably best to centralize logic in comments
 controller.

 I don't worry about field by field validation errors for comments because
 there are only 2-3 fields, instead I use:
 if ($this-BlogPost-Comment-save($this-data)) {
   $this-Session-setFlash('pComment added./p', 'default', null,
 'comment');} else {

   $this-Session-setFlash('pComment not added, correct errors and
 resubmit./p', 'default', array('class'='error'), 'comment');

 }

 And echo $this-Session-flash('comment'); in the view

 HTH, Paul.

-- 
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: SQL error 1064 in a hasMany through relationship

2011-07-20 Thread Diogo
Found the problem. I can't call functions from another controller
unless the function is declared with the Model.

On 20 jul, 00:23, Jeremy Burns | Class Outfit
jeremybu...@classoutfit.com wrote:
 What does your users controller look like?

 Jeremy Burns
 Class Outfit

 http://www.classoutfit.com

 On 20 Jul 2011, at 02:11, Diogo wrote:







  The error.

  Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
  check the manual that corresponds to your MySQL server version for the
  right syntax to use near 'index' at line 1 [CORE/cake/libs/model/
  datasources/dbo_source.php, line 684]
  Code | Context

  DboSource::showQuery() - CORE/cake/libs/model/datasources/
  dbo_source.php, line 684
  DboSource::execute() - CORE/cake/libs/model/datasources/
  dbo_source.php, line 266
  DboSource::fetchAll() - CORE/cake/libs/model/datasources/
  dbo_source.php, line 410
  DboSource::query() - CORE/cake/libs/model/datasources/dbo_source.php,
  line 364
  Model::call__() - CORE/cake/libs/model/model.php, line 502
  Overloadable::__call() - CORE/cake/libs/overloadable_php5.php, line 50
  Role::index() - [internal], line ??
  UsersController::related_clients() - APP/controllers/
  users_controller.php, line 63
  Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204
  Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
  Object::requestAction() - CORE/cake/libs/object.php, line 95
  include - APP/views/users/index.ctp, line 2
  View::_render() - CORE/cake/libs/view/view.php, line 731
  View::render() - CORE/cake/libs/view/view.php, line 426
  Controller::render() - CORE/cake/libs/controller/controller.php, line
  909
  Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 207

  On 18 jul, 18:07, Diogo dcca...@gmail.com wrote:
  UPDATE

  I created a separated project to test this. Created 3 tables (users,
  projects, roles).

  Users: id, name

  Projects: id, name

  Roles: user_id, project_id, role

  Bake them all with Cake. Now I'm trying to call Role's index function
  in Users Controller, but it gives me the same error. Could this
  possibly be a bug? Or maybe I'm missing something very stupid here. :(

  On 17 jul, 12:25, Diogo dcca...@gmail.com wrote:

  Hi David, thank you for answering.

  Well I double checked the function name, where it has been created and
  also if the model UserRole is being loaded up (by calling get_class).
  Them model/controller/view were all generated by Bake, so I guess
  everything is allright. Even when I try to call a non-custom function
  like index, it returns me the same error. It is, as you said, the
  model functions aren't being loaded. I just don't know how to do it. :
  (

  On 17 jul, 01:22, David Kullmann kullmann.da...@gmail.com wrote:

  Diogo:

  Notice how in your trace it shows this:

      Model::call__() - CORE/cake/libs/model/model.php, line 502

  Looking at the Model::call__() method you can see that it is designed
  to handle custom function calls:

  Handles custom method calls, like findByfield for DB models

  Your model does not have the method get_id_users so it is falling
  back on Model::call__() and failing. You need to make sure you are
  calling the correct method, on the correct model, and that the model
  you are calling the method on is loaded.

  -DK

  On Jul 16, 6:03 pm, Diogo dcca...@gmail.com wrote:

  I've been trying to solve this for the past 3 days and nothing has
  came up. I've researched a lot and this errors usually come up when
  CakePHP can't find my model or I have some name wrong in my
  relationships. Well I tried looking at everything, but still couldn't
  find where the error is.
  I have a User model, a Project model and a UserRole model which is the
  join table used by the hasMany through relationship.

  File names:

  user.php project.php user_role.php

  Models:

      class UserRole extends AppModel {
      ...
      var $belongsTo = array(
                  'User' = array(
                          'className' = 'User',
                          'foreignKey' = 'user_id',
                          'conditions' = '',
                          'fields' = '',
                          'order' = ''
                  ),
                  'Project' = array(
                          'className' = 'Project',
                          'foreignKey' = 'project_id',
                          'conditions' = '',
                          'fields' = '',
                          'order' = ''
                  )
          );
      class User extends AppModel {
      ...
      var $hasMany = array(
      ...
                  'UserRole' = array(
                          'className' = 'UserRole',
                          'foreignKey' = 'user_id',
                          'conditions' = '',
                          'fields' = '',
                          'order' = ''
                  ),

          );
      class Project extends AppModel {
      ...
      var $hasMany = array

Re: SQL error 1064 in a hasMany through relationship

2011-07-19 Thread Diogo
The error.

Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near 'index' at line 1 [CORE/cake/libs/model/
datasources/dbo_source.php, line 684]
Code | Context

DboSource::showQuery() - CORE/cake/libs/model/datasources/
dbo_source.php, line 684
DboSource::execute() - CORE/cake/libs/model/datasources/
dbo_source.php, line 266
DboSource::fetchAll() - CORE/cake/libs/model/datasources/
dbo_source.php, line 410
DboSource::query() - CORE/cake/libs/model/datasources/dbo_source.php,
line 364
Model::call__() - CORE/cake/libs/model/model.php, line 502
Overloadable::__call() - CORE/cake/libs/overloadable_php5.php, line 50
Role::index() - [internal], line ??
UsersController::related_clients() - APP/controllers/
users_controller.php, line 63
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
Object::requestAction() - CORE/cake/libs/object.php, line 95
include - APP/views/users/index.ctp, line 2
View::_render() - CORE/cake/libs/view/view.php, line 731
View::render() - CORE/cake/libs/view/view.php, line 426
Controller::render() - CORE/cake/libs/controller/controller.php, line
909
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 207

On 18 jul, 18:07, Diogo dcca...@gmail.com wrote:
 UPDATE

 I created a separated project to test this. Created 3 tables (users,
 projects, roles).

 Users: id, name

 Projects: id, name

 Roles: user_id, project_id, role

 Bake them all with Cake. Now I'm trying to call Role's index function
 in Users Controller, but it gives me the same error. Could this
 possibly be a bug? Or maybe I'm missing something very stupid here. :(

 On 17 jul, 12:25, Diogo dcca...@gmail.com wrote:







  Hi David, thank you for answering.

  Well I double checked the function name, where it has been created and
  also if the model UserRole is being loaded up (by calling get_class).
  Them model/controller/view were all generated by Bake, so I guess
  everything is allright. Even when I try to call a non-custom function
  like index, it returns me the same error. It is, as you said, the
  model functions aren't being loaded. I just don't know how to do it. :
  (

  On 17 jul, 01:22, David Kullmann kullmann.da...@gmail.com wrote:

   Diogo:

   Notice how in your trace it shows this:

       Model::call__() - CORE/cake/libs/model/model.php, line 502

   Looking at the Model::call__() method you can see that it is designed
   to handle custom function calls:

   Handles custom method calls, like findByfield for DB models

   Your model does not have the method get_id_users so it is falling
   back on Model::call__() and failing. You need to make sure you are
   calling the correct method, on the correct model, and that the model
   you are calling the method on is loaded.

   -DK

   On Jul 16, 6:03 pm, Diogo dcca...@gmail.com wrote:

I've been trying to solve this for the past 3 days and nothing has
came up. I've researched a lot and this errors usually come up when
CakePHP can't find my model or I have some name wrong in my
relationships. Well I tried looking at everything, but still couldn't
find where the error is.
I have a User model, a Project model and a UserRole model which is the
join table used by the hasMany through relationship.

File names:

 user.php project.php user_role.php

Models:

    class UserRole extends AppModel {
    ...
    var $belongsTo = array(
                'User' = array(
                        'className' = 'User',
                        'foreignKey' = 'user_id',
                        'conditions' = '',
                        'fields' = '',
                        'order' = ''
                ),
                'Project' = array(
                        'className' = 'Project',
                        'foreignKey' = 'project_id',
                        'conditions' = '',
                        'fields' = '',
                        'order' = ''
                )
        );
    class User extends AppModel {
    ...
    var $hasMany = array(
    ...
                'UserRole' = array(
                        'className' = 'UserRole',
                        'foreignKey' = 'user_id',
                        'conditions' = '',
                        'fields' = '',
                        'order' = ''
                ),

        );
    class Project extends AppModel {
    ...
    var $hasMany = array(
    ...
                'UserRole' = array(
                        'className' = 'UserRole',
                        'foreignKey' = 'project_id',
                        'conditions' = '',
                        'fields' = '',
                        'order

Re: SQL error 1064 in a hasMany through relationship

2011-07-18 Thread Diogo
UPDATE

I created a separated project to test this. Created 3 tables (users,
projects, roles).

Users: id, name

Projects: id, name

Roles: user_id, project_id, role

Bake them all with Cake. Now I'm trying to call Role's index function
in Users Controller, but it gives me the same error. Could this
possibly be a bug? Or maybe I'm missing something very stupid here. :(

On 17 jul, 12:25, Diogo dcca...@gmail.com wrote:
 Hi David, thank you for answering.

 Well I double checked the function name, where it has been created and
 also if the model UserRole is being loaded up (by calling get_class).
 Them model/controller/view were all generated by Bake, so I guess
 everything is allright. Even when I try to call a non-custom function
 like index, it returns me the same error. It is, as you said, the
 model functions aren't being loaded. I just don't know how to do it. :
 (

 On 17 jul, 01:22, David Kullmann kullmann.da...@gmail.com wrote:







  Diogo:

  Notice how in your trace it shows this:

      Model::call__() - CORE/cake/libs/model/model.php, line 502

  Looking at the Model::call__() method you can see that it is designed
  to handle custom function calls:

  Handles custom method calls, like findByfield for DB models

  Your model does not have the method get_id_users so it is falling
  back on Model::call__() and failing. You need to make sure you are
  calling the correct method, on the correct model, and that the model
  you are calling the method on is loaded.

  -DK

  On Jul 16, 6:03 pm, Diogo dcca...@gmail.com wrote:

   I've been trying to solve this for the past 3 days and nothing has
   came up. I've researched a lot and this errors usually come up when
   CakePHP can't find my model or I have some name wrong in my
   relationships. Well I tried looking at everything, but still couldn't
   find where the error is.
   I have a User model, a Project model and a UserRole model which is the
   join table used by the hasMany through relationship.

   File names:

user.php project.php user_role.php

   Models:

       class UserRole extends AppModel {
       ...
       var $belongsTo = array(
                   'User' = array(
                           'className' = 'User',
                           'foreignKey' = 'user_id',
                           'conditions' = '',
                           'fields' = '',
                           'order' = ''
                   ),
                   'Project' = array(
                           'className' = 'Project',
                           'foreignKey' = 'project_id',
                           'conditions' = '',
                           'fields' = '',
                           'order' = ''
                   )
           );
       class User extends AppModel {
       ...
       var $hasMany = array(
       ...
                   'UserRole' = array(
                           'className' = 'UserRole',
                           'foreignKey' = 'user_id',
                           'conditions' = '',
                           'fields' = '',
                           'order' = ''
                   ),

           );
       class Project extends AppModel {
       ...
       var $hasMany = array(
       ...
                   'UserRole' = array(
                           'className' = 'UserRole',
                           'foreignKey' = 'project_id',
                           'conditions' = '',
                           'fields' = '',
                           'order' = ''
                   ),
           );
   When I try calling any method from UserRole from User, it give me the
   1064 SQL error. Any hint on where could be the problem?

   Things I've tried so far: checked if UserRole is being loaded, and it
   is. And I can call the UserRole functions from an element, they are
   working fine.

   FUNCTIONS (get_related_clients is in Users and the other is in
   UserRoles):

       function get_related_clients ($id_user, $relationship_type) {
           $id_names = $this-User-UserRole-get_id_users($id_user,
   $relationship_type);
           ...
       }
       function get_id_users ($id_agency = null,$type = null) {
                   $params_1 = array(
                           'conditions' = array('UserRole.user_id' = 
   $id_agency)
                   );
                   $user_projects = $this-UserRole-find('all',$params_1);
                   $projects = array();
                   for ($i = 0; !empty($user_projects[$i]); $i++) {
                           $projects[] = 
   $user_projects[$i]['UserRole']['project_id'];
                   }
                   $clients = array();
                   foreach ($projects as $project) { //pega o id de todos os 
   usuarios
   que sao clientes da lista de projetos anteriores
                           $params_2 = array(
                                   'conditions' = 
   array('UserRole.project_id' = $project,
   'UserRole.role' = $type

Re: SQL error 1064 in a hasMany through relationship

2011-07-17 Thread Diogo
Hi David, thank you for answering.

Well I double checked the function name, where it has been created and
also if the model UserRole is being loaded up (by calling get_class).
Them model/controller/view were all generated by Bake, so I guess
everything is allright. Even when I try to call a non-custom function
like index, it returns me the same error. It is, as you said, the
model functions aren't being loaded. I just don't know how to do it. :
(

On 17 jul, 01:22, David Kullmann kullmann.da...@gmail.com wrote:
 Diogo:

 Notice how in your trace it shows this:

     Model::call__() - CORE/cake/libs/model/model.php, line 502

 Looking at the Model::call__() method you can see that it is designed
 to handle custom function calls:

 Handles custom method calls, like findByfield for DB models

 Your model does not have the method get_id_users so it is falling
 back on Model::call__() and failing. You need to make sure you are
 calling the correct method, on the correct model, and that the model
 you are calling the method on is loaded.

 -DK

 On Jul 16, 6:03 pm, Diogo dcca...@gmail.com wrote:







  I've been trying to solve this for the past 3 days and nothing has
  came up. I've researched a lot and this errors usually come up when
  CakePHP can't find my model or I have some name wrong in my
  relationships. Well I tried looking at everything, but still couldn't
  find where the error is.
  I have a User model, a Project model and a UserRole model which is the
  join table used by the hasMany through relationship.

  File names:

   user.php project.php user_role.php

  Models:

      class UserRole extends AppModel {
      ...
      var $belongsTo = array(
                  'User' = array(
                          'className' = 'User',
                          'foreignKey' = 'user_id',
                          'conditions' = '',
                          'fields' = '',
                          'order' = ''
                  ),
                  'Project' = array(
                          'className' = 'Project',
                          'foreignKey' = 'project_id',
                          'conditions' = '',
                          'fields' = '',
                          'order' = ''
                  )
          );
      class User extends AppModel {
      ...
      var $hasMany = array(
      ...
                  'UserRole' = array(
                          'className' = 'UserRole',
                          'foreignKey' = 'user_id',
                          'conditions' = '',
                          'fields' = '',
                          'order' = ''
                  ),

          );
      class Project extends AppModel {
      ...
      var $hasMany = array(
      ...
                  'UserRole' = array(
                          'className' = 'UserRole',
                          'foreignKey' = 'project_id',
                          'conditions' = '',
                          'fields' = '',
                          'order' = ''
                  ),
          );
  When I try calling any method from UserRole from User, it give me the
  1064 SQL error. Any hint on where could be the problem?

  Things I've tried so far: checked if UserRole is being loaded, and it
  is. And I can call the UserRole functions from an element, they are
  working fine.

  FUNCTIONS (get_related_clients is in Users and the other is in
  UserRoles):

      function get_related_clients ($id_user, $relationship_type) {
          $id_names = $this-User-UserRole-get_id_users($id_user,
  $relationship_type);
          ...
      }
      function get_id_users ($id_agency = null,$type = null) {
                  $params_1 = array(
                          'conditions' = array('UserRole.user_id' = 
  $id_agency)
                  );
                  $user_projects = $this-UserRole-find('all',$params_1);
                  $projects = array();
                  for ($i = 0; !empty($user_projects[$i]); $i++) {
                          $projects[] = 
  $user_projects[$i]['UserRole']['project_id'];
                  }
                  $clients = array();
                  foreach ($projects as $project) { //pega o id de todos os 
  usuarios
  que sao clientes da lista de projetos anteriores
                          $params_2 = array(
                                  'conditions' = array('UserRole.project_id' 
  = $project,
  'UserRole.role' = $type)
                          );
                          $client_project = 
  $this-UserRole-find('first',$params_2);
                          if ($id_agency != 
  $client_project['UserRole']['user_id'])
  { $clients[] = $client_project['UserRole']['user_id']; } // voce nao
  pode ser cliente de voce mesmo
                  }
                  return $clients;
          }

  ERROR:

       Warning (512): SQL Error: 1064: You have an error in your SQL
  syntax; check the manual that corresponds to your MySQL server version
  for the right syntax to use near

SQL error 1064 in a hasMany through relationship

2011-07-16 Thread Diogo
I've been trying to solve this for the past 3 days and nothing has
came up. I've researched a lot and this errors usually come up when
CakePHP can't find my model or I have some name wrong in my
relationships. Well I tried looking at everything, but still couldn't
find where the error is.
I have a User model, a Project model and a UserRole model which is the
join table used by the hasMany through relationship.

File names:

 user.php project.php user_role.php

Models:

class UserRole extends AppModel {
...
var $belongsTo = array(
'User' = array(
'className' = 'User',
'foreignKey' = 'user_id',
'conditions' = '',
'fields' = '',
'order' = ''
),
'Project' = array(
'className' = 'Project',
'foreignKey' = 'project_id',
'conditions' = '',
'fields' = '',
'order' = ''
)
);
class User extends AppModel {
...
var $hasMany = array(
...
'UserRole' = array(
'className' = 'UserRole',
'foreignKey' = 'user_id',
'conditions' = '',
'fields' = '',
'order' = ''
),

);
class Project extends AppModel {
...
var $hasMany = array(
...
'UserRole' = array(
'className' = 'UserRole',
'foreignKey' = 'project_id',
'conditions' = '',
'fields' = '',
'order' = ''
),
);
When I try calling any method from UserRole from User, it give me the
1064 SQL error. Any hint on where could be the problem?

Things I've tried so far: checked if UserRole is being loaded, and it
is. And I can call the UserRole functions from an element, they are
working fine.

FUNCTIONS (get_related_clients is in Users and the other is in
UserRoles):

function get_related_clients ($id_user, $relationship_type) {
$id_names = $this-User-UserRole-get_id_users($id_user,
$relationship_type);
...
}
function get_id_users ($id_agency = null,$type = null) {
$params_1 = array(
'conditions' = array('UserRole.user_id' = $id_agency)
);
$user_projects = $this-UserRole-find('all',$params_1);
$projects = array();
for ($i = 0; !empty($user_projects[$i]); $i++) {
$projects[] = 
$user_projects[$i]['UserRole']['project_id'];
}
$clients = array();
foreach ($projects as $project) { //pega o id de todos os 
usuarios
que sao clientes da lista de projetos anteriores
$params_2 = array(
'conditions' = array('UserRole.project_id' = 
$project,
'UserRole.role' = $type)
);
$client_project = 
$this-UserRole-find('first',$params_2);
if ($id_agency != 
$client_project['UserRole']['user_id'])
{ $clients[] = $client_project['UserRole']['user_id']; } // voce nao
pode ser cliente de voce mesmo
}
return $clients;
}

ERROR:



 Warning (512): SQL Error: 1064: You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'get_id_users' at line 1
DboSource::showQuery() - CORE/cake/libs/model/datasources/
dbo_source.php, line 684
DboSource::execute() - CORE/cake/libs/model/datasources/
dbo_source.php, line 266
DboSource::fetchAll() - CORE/cake/libs/model/datasources/
dbo_source.php, line 410
DboSource::query() - CORE/cake/libs/model/datasources/
dbo_source.php, line 364
Model::call__() - CORE/cake/libs/model/model.php, line 502
Overloadable::__call() - CORE/cake/libs/overloadable_php5.php,
line 50
UserRole::get_id_users() - [internal], line ??
UsersController::get_related_clients() - APP/controllers/
users_controller.php, line 71
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
Object::requestAction() - CORE/cake/libs/object.php, line 95
include - APP/views/elements/client_list.ctp, line 2
View::_render() - CORE/cake/libs/view/view.php, line 731
View::element() - CORE/cake/libs/view/view.php, line 392
include - APP/views/projects/index.ctp, line 45
View::_render() - CORE/cake/libs/view/view.php, line 731

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

Control function access without Auth

2011-07-05 Thread Diogo
Hi guys.

I was wondering, what is the best way to control one function access
without the use of the Auth component? The main thing I wanted to do
is make sure that one function can only be called through one exact
view, and no one else could just type it on the address bar it. Does
ACL requires the use of Auth to work?

Thanks!

-- 
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: Slow connection to Data base

2011-04-26 Thread Diogo Hartmann
Something interesting to add:
When I use a localhost database the page are dispalyed very fast.

Is anything wrong with usign an external database?


Atenciosamente,

Diogo Hartmann

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


How to validate a dropdown list with months

2011-02-13 Thread Diogo
Hi! I've been seraching for weeks how to do that but didn't find any
good answer. I mean I thought it was supposed to be easy to do that,
but not at all. Here's the thing, I have to ask the user to choose a
month interval so I can show the right data to him. Since it's not
related to any table I have on my database, I just did this (sorry
don't know how to put tags to format as a code):

?php
echo $this-Form-create(false);
echo $this-Form-month('m1', null, array('monthNames' = false));
echo ' until ';
echo $this-Form-month('m2', null, array('monthNames' = false));
echo $this-Form-end('Choose');
?

And then created a simple rule at the model (there's only a rule for
one field, for test purpose):

var $validate = array('m1' = array('rule' = 'notEmpty', 'required'
= true, 'message' = 'Error!'));

Here's my controller:

function choose_date ($id = null) {
if (!empty($this-data)) {
$this-Frequency-set($this-data);
if ($this-Frequency-validates()) {
$fD = $this-data['m1']['month'].'/'.date('Y');
$tD = $this-data['m2']['month'].'/'.date('Y');
$this-Session-write('Frequency.fromDate', 
$fD);
$this-Session-write('Frequency.toDate', $tD);
$this-redirect(array('action' = 'view'));
}
} else { $this-Session-write('Worker.id', $id); }
}

So what happens is that it just freezes at the choose_date view,
doesn't matter if do or don't select anything on the list. How can I
validate it?  It's probably a simple task but it's getting me crazy!

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