I am using Yii with PHP and with Sql Server 2008 R2. Can anyone tell me where is the problem ?
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Hold']))
{
$model->attributes=$_POST['Hold'];
$model->startTimeHour=cc("select code from Lookup where name='$model->startTime' and type='starttime'")->queryScalar();
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('update',array(
'model'=>$model,
));
}
Model $model->startTime Holds values in Dropdown. Here is the code of that as well.
<div class="control-group">
<label class="control-label"><?php echo $form->labelEx($model,'startTime'); ?></label>
<div class="controls">
<?php echo $form->dropDownList($model,'startTime',$this->_startTime); ?>
<span class="help-inline"><?php echo $form->error($model,'startTime'); ?></span>
</div>
</div>
But Clicking On Save Button getting this error on line below…
CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY090]: [Microsoft][ODBC Driver Manager] Invalid string or buffer length. The SQL statement executed was:
Error is on this line
$model->startTimeHour=cc("select code from Lookup where name='$model->startTime' and type='starttime'")->queryScalar();