Thanks. I hope it is actually something wrong on my end.
Here is more information:
Database table:
CREATE TABLE `deliverable` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`tenant_id` int(11) NOT NULL,
`name` varchar(45) NOT NULL,
`original_end_date` date NOT NULL,
`current_end_date` date DEFAULT NULL,
`actual_end_date` date DEFAULT NULL,
`percent_complete` int(11) DEFAULT '0',
`date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`user_created` varchar(10) NOT NULL,
`date_updated` timestamp NULL DEFAULT NULL,
`user_updated` varchar(10) DEFAULT NULL,
`project_id` int(11) NOT NULL,
`person_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_deliverable_project1` (`project_id`),
KEY `fk_deliverable_person1` (`person_id`),
CONSTRAINT `fk_deliverable_person1` FOREIGN KEY (`person_id`) REFERENCES `person` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_deliverable_project1` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1$$
Model:
..
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'comments' => array(self::HAS_MANY, 'Comment', 'deliverable_id'),
'commentCount' => array(self::STAT, 'Comment', 'deliverable_id'),
'person' => array(self::BELONGS_TO, 'Person', 'person_id'),
'project' => array(self::BELONGS_TO, 'Project', 'project_id'),
);
}
.....
public function defaultScope()
{
return array(
'condition'=>'project_id='.Yii::App()->user->projectId
.' and tenant_id='.Yii::App()->user->tenantId
);
}
Code to retrieve data:
<?php
class getDueDeliverables extends CPortlet
{
public $title='Due Deliverables';
public function getDueDeliverables()
{
return Deliverable::model()->resetScope()->findAll();
}
protected function renderContent()
{
$this->render('getDueDeliverableView');
}
}
Error message:
Stack (1): line 141 highlighted
C:\xampp\htdocs\yiiMain\framework\web\auth\CWebUser.php(141)
129
130 /**
131 * PHP magic method.
132 * This method is overriden so that persistent states can be accessed like properties.
133 * @param string $name property name
134 * @return mixed property value
135 */
136 public function __get($name)
137 {
138 if($this->hasState($name))
139 return $this->getState($name);
140 else
141 return parent::__get($name);
142 }
143
144 /**
145 * PHP magic method.
146 * This method is overriden so that persistent states can be set like properties.
147 * @param string $name property name
148 * @param mixed $value property value
149 */
150 public function __set($name,$value)
151 {
152 if($this->hasState($name))
153 $this->setState($name,$value);
line 155 highlighted
C:\xampp\htdocs\mypmapp\protected\models\Deliverable.php(155): CWebUser->__get("projectId")
150 }
151
152 public function defaultScope()
153 {
154 return array(
155 'condition'=>'project_id='.Yii::App()->user->projectId
156 .' and tenant_id='.Yii::App()->user->tenantId
157 );
158 }
159
160 /**