You don't need a lot of the code you have written as Cake does it for you, 
assuming you write it correctly.

If you have a table 'groups' this is all you need:

/app/controllers/groups_controller.php
class GroupsController extends AppController {

        var $name = "Groups";
        var $components = array(....);

etc...

/app/models/group.php
class Group extends AppModel {
        var $name = "Group";
        var $primaryKey = 'id_group';
        

Then your find ought to work.

Note that Cake automatically ties the 'groups' table to the right model, and 
connects the right controller to the right model too. You need to make sure 
your filenames are right too.

Jeremy Burns
Class Outfit

[email protected]
http://www.classoutfit.com

On 17 Feb 2011, at 03:42, [email protected] wrote:

> I change names but my problem don't solved.
> 
> Undefined property: GroupsController::$Group [APP/controllers/
> groups_controller.php, line 30]
> 
> 
> On 17 Lut, 03:51, "Krissy Masters" <[email protected]> wrote:
>> Names are backwards.
>> 
>> Controllers are plural
>> class GroupsController extends AppController {
>> 
>> Models are singular
>> class Group extends AppModel {
>> 
>> K
>> 
>> -----Original Message-----
>> From: [email protected] [mailto:[email protected]] On Behalf
>> 
>> Of [email protected]
>> Sent: Wednesday, February 16, 2011 11:17 PM
>> To: CakePHP
>> Subject: Big problem with using Model 1.3
>> 
>> Hi everyone.
>> I have a big problem. I create model and controller:
>> 
>> class GroupController extends AppController {
>>     var $name = 'Group';
>>     var $uses = array('Groups');
>>     var $components = array('Session', 'Auth');
>> 
>> class Groups extends AppModel {
>>     var $name = 'Groups';
>>     var $useTable = 'groups';
>>     var $primaryKey = 'id_group';
>> 
>> When I use:
>> 
>>  $user = $this->Group->find('all');
>> 
>> I see this error:
>> Undefined property: GroupController::$Groups [APP/controllers/
>> group_controller.php, line 30]
>> 
>> Fatal error: Call to a member function find() on a non-object in /home/
>> public_html/simple/app/controllers/group_controller.php on line 30
>> 
>> I know that I can use
>>         $this->loadModel('Groups');
>>         $groups = $this->Groups->find('all');
>> this work but I need associations in future. I don't know what is
>> going on. I use 1.3.6.
>> 
>> Sorry for my English.
>> Thanks for help
>> 
>> --
>> Our newest site for the community: CakePHP Video 
>> Tutorialshttp://tv.cakephp.org
>> Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
>> others with their CakePHP related questions.
>> 
>> To unsubscribe from this group, send email to
>> [email protected] For more options, visit this group 
>> athttp://groups.google.com/group/cake-php
>> 
>> 
> 
> -- 
> 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
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
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
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to