Yii Framework Forum: Ch8 - error with Project::associateUserToRole method - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ch8 - error with Project::associateUserToRole method CException: Property "CDbCommand.execute" is not defined

#1 User is offline   edward_bw 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 04-November 10

Posted 15 February 2011 - 06:08 AM

Hi - I have been following the book and have an issue with chapter 8 on page 191 -> 194 (Implementing the new Project AR methods.)

I've created the RBAC tables/details successfully in both _test and _dev.
I've added the code to Project.php and ProjectTest.php

After I've added in the sql to associateUserToRole() I was expecting to run the phpunit unit/ProjectTest.php test and it to pass - instead I get the following:

______________________________________________________________________________________
D:\Zend\Apache2\htdocs\trackstar\protected\tests>phpunit unit/ProjectTest.php

Notice: Please no longer include "PHPUnit/Framework.php". in D:\Zend\ZendServer\
bin\pear\PHPUnit\Framework.php on line 50
PHPUnit 3.5.5 by Sebastian Bergmann.

.....E

Time: 4 seconds, Memory: 9.25Mb

There was 1 error:

1) ProjectTest::testUserRoleAssignment
CException: Property "CDbCommand.execute" is not defined.

D:\Zend\Apache2\htdocs\yii114\framework\base\CComponent.php:131
D:\Zend\Apache2\htdocs\trackstar\protected\models\Project.php:127
D:\Zend\Apache2\htdocs\trackstar\protected\tests\unit\ProjectTest.php:95

FAILURES!
Tests: 6, Assertions: 13, Errors: 1.
______________________________________________________________________________

Not quite sure where I've gone wrong - any help gratefully received.
Thanks,
Ed
0

#2 User is offline   edward_bw 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 04-November 10

Posted 15 February 2011 - 06:58 AM

I think the problem is that the code in models/Project.php is referencing the wrong part of the yii app.

The code : $command = Yii::app()->db->createCommand($sql);

This should resolve to ...\yii114\framework\db : CDbCommand.php
but in the error above it resolves to : ...\yii114\framework\base\CComponent.php

Not sure how I (or even if I need to) change Yii::app()->db to the correct directory ?

Any help ?
0

#3 User is offline   edward_bw 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 04-November 10

Posted 15 February 2011 - 08:00 AM

Fixed.
Had missed out the method brackets on the return from Project::associateUserToRole()...

Wrong : return $command->execute;
Right : return $command->execute();

Doh....
0

#4 User is offline   jefftulsa 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 168
  • Joined: 06-October 08
  • Location:Austin, TX

Posted 15 February 2011 - 06:15 PM

View Postedward_bw, on 15 February 2011 - 08:00 AM, said:

Fixed.
Had missed out the method brackets on the return from Project::associateUserToRole()...

Wrong : return $command->execute;
Right : return $command->execute();

Doh....



yes, this is an identified issue with the printing of the book (#10 in the identified issues thread).
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users