When does the error occur? Just by accessing the "view" page, or by doing something in the "view" page?
And could you show your "view.php"?
When does the error occur? Just by accessing the "view" page, or by doing something in the "view" page?
And could you show your "view.php"?
Hi… I have attached the view.php file… The error occurs when clicking for a search of value in the textfield.
view.php
<?php
$this->breadcrumbs=array(
'Task Infos'=>array('index'),
$model->task_id,
);
$this->menu=array(
array('label'=>'List TaskInfo', 'url'=>array('index')),
array('label'=>'Create TaskInfo', 'url'=>array('create')),
array('label'=>'Update TaskInfo', 'url'=>array('update', 'id'=>$model->task_id)),
array('label'=>'Delete TaskInfo', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->task_id),'confirm'=>'Are you sure you want to delete this item?')),
array('label'=>'Manage TaskInfo', 'url'=>array('admin')),
);
?>
<h1>View TaskInfo #<?php echo $model->task_id; ?></h1>
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'task_id',
'task_name',
array(
'name'=>'project_id',
'value'=>CHtml::encode($model->project->project_name)
),
array(
'name'=>'task_type_id',
'value'=>CHtml::encode($model->taskType->task_type_name)
),
'task_des',
'task_end_date',
'totaltime',
array(
'name'=>'emp_id',
'value'=>CHtml::encode($model->emp->emp_name)
),
'task_create_at',
'uploads',
),
));
if ( $model2 !== null ) // only when $model2 is set
{
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'task-feed-grid',
'dataProvider'=>$model2->search(),
'filter'=>$model2,
'columns'=>array(
'taskfeed_id',
array(
'name'=>'task_id',
'value'=>'$data->task->task_name',
),
'title',
'taskfeed_des',
array(
'name'=>'points_id',
'value'=>'$data->points->points_range',
),
array(
'name'=>'emp_id',
'value'=>'$data->emp->emp_name',
),
/*
'posted_it',
'upload',
*/
array(
'class'=>'CButtonColumn',
),
),
));
}
?>
And also i want to know that the condition used in search function that is in TaskInfo.php(below mentioned)
is right method to get values or else how to do so…
//TaskInfo.php
$criteria=new CDbCriteria;
if(isset($_GET['id'])){
$id=$_GET['id'];
$criteria->condition="project_id=$id";
}
thanks…
Isn’t that “view.php” of TaskInfo? I thought that the error occurs in the “view” page of ProjectInfo …
Anyway, I think your "actionView" function in ProjectInfoController needs some corrections.
The parameter $id is the PK of ProjectInfo, i.e. “project_id”. Isn’t it? And it can never be “null”.
So, it should be:
public function actionView($id)
{
$model2 = new TaskInfo('search');
$model2->unsetAttributes();
$model2->project_id = $id;
if (isset($_GET['TaskInfo']))
{
$model2->attributes = $_GET['TaskInfo'];
}
$this->render('view',array(
'model'=>$this->loadModel($id),
'model2'=>$model2,
));
}
......
Note that $_GET[‘TaskInfo’] is an array, so $model2->task_id = $_GET[‘TaskInfo’] will cause a trouble.
There’s no need to do that.
$model2->project_id = $id;
has already done it.
And, besides that, using an un-escaped input in a condition is unsafe.
It’s not a good practice to look up $_GET from inside a model.
Hi…
Thank you Soo Much for your Valueable Guideness and Time…
Some how i managed with all data’s now … It is now working without any issue… Moving forward i need all your support to do better programming…
Thanks
Aruna
In this line $model2->xxxx = $id;
what was XXXX attribute for your database?
I have done the same it’s working nice. but like you said in below post for filtering data $model2->task_id = $id;
which gives me error.
I have two table
Event : Event has many task
Task : In this table there is event_id
I got this error.
CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'event_id' in where clause is ambiguous. The SQL statement executed was: SELECT COUNT(DISTINCT `t`.`task_id`) FROM `task` `t` LEFT OUTER JOIN `event` `event` ON (`t`.`event_id`=`event`.`event_id`) LEFT OUTER JOIN `user` `user` ON (`t`.`user_id`=`user`.`user_id`) WHERE (event_id=:ycp0). Bound with :ycp0='1'
Without $model->event_id condition it’s worked great. and
Aslo list of edit and view will be same as current model.
It gives --> http://localhost/event_tracking/trunk/event/update/1
I require --> http://localhost/event_tracking/trunk/task/update/1